如何通过删除按钮删除datagridview中的选定行

时间:2013-03-10 18:35:39

标签: c#

SqlConnection con = new SqlConnection( "Data Source=AMBADNYA-PC;Initial
         Catalog=MYRAWPRO;Persist Security Info=True;User ID=sa;Password=sa");

string query = "DELETE FROM Sales  WHERE Sales_ID =" + 
                dataGridViewProduct.SelectedRows[0].Cells[0].Value.ToString();

SqlCommand com = new SqlCommand();

com.CommandText = query;
com.Connection = con;
con.Open();
com.ExecuteNonQuery();
con.Close();

MessageBox.Show("Deleted");

但显示错误

Invalid column name 'uiui'.

uiui是列值。我做错了什么?

0 个答案:

没有答案