首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

dataGridView显示删除成功了,但是数据库里面数据还在,该怎么处理

2012-01-10 
dataGridView显示删除成功了,但是数据库里面数据还在stringstrConn@ ProviderMicrosoft.Jet.OLEDB.4.0

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 + " ";
没有正确的执行!

热点排行