错误笔记:在OleDb执行下Access ,程序不报错,但是Update也更新不成功的
时间:2010-09-08 来源:破浪
http://blog.sina.com.cn/s/blog_4668898b010008io.html( OLEDB传递参数给Access要注意的问题)
代码
string sql = @"update UserInfo set
[RoleID] = @RoleID,
[UserName] = @UserName,
[PWD] = @PWD,
[Email] = @Email
where [UserIdentity] = @UserIdentity ";
DbCommand cmd = dbHelper.GetSqlStringCommond(sql
);
dbHelper.AddParameterCollection(cmd,
new OleDbParameter("UserIdentity", user.UserIdentity),//注意UserIdentity放置位置
new OleDbParameter("RoleID", user.RoleID),
new OleDbParameter("UserName", user.UserName),
new OleDbParameter("PWD", user.PWD),
new OleDbParameter("Email", user.Email)
);
修改后的Code(运行成功):
代码 string sql = @"update UserInfo set
[RoleID] = @RoleID,
[UserName] = @UserName,
[PWD] = @PWD,
[Email] = @Email
where [UserIdentity] = @UserIdentity ";
DbCommand cmd = dbHelper.GetSqlStringCommond(sql
);
dbHelper.AddParameterCollection(cmd,
new OleDbParameter("RoleID", user.RoleID),
new OleDbParameter("UserName", user.UserName),
new OleDbParameter("PWD", user.PWD),
new OleDbParameter("Email", user.Email),
new OleDbParameter("UserIdentity", user.UserIdentity)//注意UserIdentity放置位置
);