0
I have a program in which I wanted to present two tables of my database in one datagridview, these two tables have relation of n to n but I don’t know how I can see the second table.
Step to demonstrate the code :
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text != "")
{
Database.DatabaseAPI.NonQuery("INSERT INTO Jogador(Id_Jogador, Nome, Idade, País, id_equipa) Values (NewID(), '" + textBox1.Text.Replace("'", "''") + "', '" + textBox2.Text.Replace("'", "''") + "', '" + textBox3.Text.Replace("'", "''") + "', '" + comboBox1.ValueMember.ToString() + "')");
if (textBox1.Text.Trim() == string.Empty)
{
MessageBox.Show("Nome em Falta");
return;
}
if (textBox2.Text.Trim() == string.Empty)
{
MessageBox.Show("Idade em Falta");
return;
}
if (textBox3.Text.Trim() == string.Empty)
{
MessageBox.Show("País em Falta");
return;
}
MessageBox.Show("Dados do Jogador adicionado com sucesso!");
DataTable dataTable = Database.DatabaseAPI.SelectDataTable("Select Id_Jogador, Nome, Idade, País, id_jogador From Jogador");
dataGridView1.DataSource = dataTable;
}
}
I was able to make the team list in one combobox but I do not know how I can do for when select already get the player data rights.
Database :
Can someone help me?
Pass the schematic of the tables you want to display so that we can make a proper query for your problem.
– Augusto Vasques
There’s a database here for a little extra help.
– Jose Badim