我正在研究一个项目,我在navicat上添加了一个查询,显示了我想要的结果,但是当我在项目中使用相同的查询时,它只显示了5行结果。
用于填充datagridview并获取数据的代码如下。
string cs = "*info*";
MySqlConnection liga = new MySqlConnection(cs);
string query = "*I have the full query futher down, its big and it looks stange in here*";
MySqlCommand comando = new MySqlCommand(query, liga);
int nInt = Convert.ToInt32(textBox1.Text);
comando.Parameters.AddWithValue("@ni", nInt);
try
{
liga.Open();
MySqlDataReader leitor = comando.ExecuteReader();
DataTable tabela = new DataTable();
tabela.Load(leitor);
dataGridView1.DataSource = tabela;
leitor.Close();
}
catch (MySqlException ex)
{
MessageBox.Show(ex.Message);
}
finally
{
liga.Close();
}
QUERY
SELECT
disciplinas.nome AS Disciplina,
mods_alunos.numero,
mods_alunos.nota
FROM
mods_alunos
INNER JOIN disciplinas ON mods_alunos.codDisc = disciplinas.codDisc
WHERE
nInterno = @ni
我得出的结论是它与INNER JOIN有关,因为我只是做SELECT * FROM mods_alunos它显示超过5个结果