紧急求助,ACCESS数据库无法删除记录,在线等待,谢谢!
代码如下:
string strConn = null;
DbManager objDb = new DbManager();
strConn = objDb.GetConnectionString(strStartupPath);
OleDbConnection objConn = new OleDbConnection(strConn);
OleDbCommand objComm = new OleDbCommand();
objConn.ConnectionString = strConn;
objConn.Open();
objComm.Connection = objConn;
//删除收藏
try
{
objComm.CommandText = "Delete From Favorites Where MovieName = ' " + strMovieName + " ' ";
objComm.ExecuteNonQuery();
}
catch (OleDbException e)
{
Console.WriteLine(e.Message);
}
finally
{
objComm.Dispose();
objConn.Dispose();
}
connection是正常的,但程序抛出异常“至少有一个参数没有指定值”,请问是为什么?谢谢
------解决方案--------------------strMovieName,这个是什么意思,是变量还是常量。我估计是这问题
------解决方案-------------------- "Delete From Favorites Where MovieName = ' " + strMovieName + " ' ";
把这一句简化一下,
"Delete From Favorites Where MovieName = ' strMovieName ' ";
弄成这种形式,strMovieName这个值是多少我不清空,你直接打进去好了,看他还报错没。
------解决方案--------------------