我收到以下错误:
您指定了无效的列序号
我已经检查了数据库中的列号,我知道它是正确的。这是我的代码:
using (MySqlCommand cmd = new MySqlCommand(query, con))
{
cmd.Parameters.AddWithValue("@ID", txtboxID.Text);
MySqlDataReader dr = cmd.ExecuteReader();
while(dr.Read())
{
int size = dr.GetInt32(3);
int quantity = dr.GetInt32(4);
string variant = dr.GetString(2);
DataGridViewRow row = dataGridView2.Rows
.Cast<DataGridViewRow>()
.Where(r => (r.Cells["variant_name"].Value.ToString().Equals(variant) && r.Cells["size"].Value.Equals(size)))
.First();
row.Cells["quantity"].Value = quantity;
}
}
我在这一行收到错误->int size = dr.GetInt32(3);