日期:2014-05-19  浏览次数:20940 次

dataGridView显示删除成功了,但是数据库里面数据还在
string   strConn   =   @ "Provider   =   Microsoft.Jet.OLEDB.4.0;Data   Source=|DataDirectory|\data.mdb ";
OleDbConnection   conn   =   new   OleDbConnection(strConn);
conn.Open();

int   ID   =   Int32.Parse(this.dataGridView1.CurrentRow.Cells[0].Value.ToString());
string   selectStr   =   "delete     from   shop   where   id   =   "   +   ID   +   " ";
OleDbCommand   thisComm   =   conn.CreateCommand();
thisComm.CommandText   =   selectStr;
try
{
        thisComm.ExecuteNonQuery();
}
catch
{
      throw;
}
finally
{
        thisComm.Dispose();
        conn.Close();
}

this.dataGridView1.Rows.Remove(this.dataGridView1.CurrentRow);

在dataGridView上面实现数据已经没有了,但是打开数据库看下,那条数据还在。。。

------解决方案--------------------
ID是不是取的不对而使
delete from shop where id = " + ID + " ";
没有正确的执行!