如何在删除datagrid一行同时将对应数据库一行数据也删除?
private void btnDel_Click(object sender, EventArgs e)
{
dataGridView2.Rows.RemoveAt(dataGridView2.CurrentRow.Index);
string con = "workstation id=WYF-410179178\\SQL2005;integrated security=SSPI;data source=WYF-410179178\\SQL2005;initial catalog=ZGRCJY";
SqlConnection mycon = new SqlConnection(con);
myCommand = mycon.CreateCommand();
mycon.Open();
string sql = "delete from tblZGJCMX where ZGID= ' " + dataGridView2.CurrentRow.Cells[0].Value + " ' ";
myCommand.CommandText = sql;
myCommand.ExecuteNonQuery();
mycon.Close();
}
数据库中数据无法删除,请问高手