我正在尝试删除包含在 datagridview 中显示的匹配文本的记录。我得到了字符串,似乎没有任何问题,但没有任何记录被删除。
String text;
int i = dataGridView1.CurrentRow.Index;
text = (string)dataGridView1[0, i].Value.ToString();
String deleteSql = "DELETE FROM [Sugg] WHERE sugg_text='"+text+"'";
MessageBox.Show(text);
if (MessageBox.Show("Are you sure you want to delete this suggestion?", "Title", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
try
{
oleDbConnection1.Open();
oleDbDataAdapter1.DeleteCommand = oleDbConnection1.CreateCommand();
oleDbDataAdapter1.DeleteCommand.CommandText = deleteSql;
oleDbDataAdapter1.DeleteCommand.ExecuteNonQuery();
oleDbConnection1.Close();