我正在努力实现以下目标:
I have my first grid which shows the entries from my db table foo
, when selecting one, I need to recover from column[0] cell[0], an id which I'll use for a query afterwards. 此查询将使用来自 的所有一对多实例填充 grid2 table bar
。但我得到一个空点异常,我不知道为什么......
private void button1_Click_1(object sender, EventArgs e)
{
SqlConnection sc = new SqlConnection(@"Data Source = WARZARU-NB\SQLEXPRESS; Database = proj_1; Integrated Security = True");
dataSet.Clear();
dataAdapter.SelectCommand = new SqlCommand("select * from students WHERE id=@index", sc);
// EXCEPTION here
dataAdapter.InsertCommand.Parameters.Add("@index", SqlDbType.Int).Value = dgParent.CurrentCell.Value;
dataAdapter.Fill(dataSet, "grades");
dgChild.DataSource = dataSet.Tables["grades"];
dgParent.AutoResizeColumns();
dgParent.AutoResizeRows();
}