AccessUPdate标准表达式中数据类型不匹配
⼀直没机会⽤ASP.NET操作ACCESS数据库,今天⼀⽤就让我遇到⼀个很奇怪的问题
在UPdate操作时遇到⼀个"标准表达式中数据类型不匹配"错误~到现在我也没搞明是什么原因,添加,删除,查询都没问题,就只有在更新操作时会有问题,我尝试了⼀下将ID直接写到字符串中,不通过参数,这样就成功了
问题代码:
StringBuilder strSql = new StringBuilder();
strSql.Append("update RGP_AuthorityDir set ");
strSql.Append(",");
strSql.Append(",");
strSql.Append(",");
strSql.Append("");
strSql.Append(" where ");
OleDbParameter[] parameters = {
new OleDbParameter("@AuthorityID", OleDbType.Integer,11),
new OleDbParameter("@AuthorityName", OleDbType.VarWChar,30),
new OleDbParameter("@AuthorityTag", OleDbType.VarWChar,50),
new OleDbParameter("@AuthorityDescription", OleDbType.VarWChar,50),
new OleDbParameter("@AuthorityOrder", OleDbType.Integer,11)};
parameters[0].Value = model.AuthorityID;
parameters[1].Value = model.AuthorityName;
parameters[2].Value = model.AuthorityTag;
parameters[3].Value = model.AuthorityDescription;
parameters[4].Value = model.AuthorityOrder;
解决办法
StringBuilder strSql = new StringBuilder();
update是什么strSql.Append("update RGP_AuthorityDir set ");
strSql.Append(",");
strSql.Append(",");
strSql.Append(",");
strSql.Append("");
strSql.Append(" where AuthorityID=" + model.AuthorityID);
OleDbParameter[] parameters = {
new OleDbParameter("@AuthorityName", OleDbType.VarWChar,30),
new OleDbParameter("@AuthorityTag", OleDbType.VarWChar,50),
new OleDbParameter("@AuthorityDescription", OleDbType.VarWChar,50),
new OleDbParameter("@AuthorityOrder", OleDbType.Integer,11)};
parameters[0].Value = model.AuthorityName;
parameters[1].Value = model.AuthorityTag;
parameters[2].Value = model.AuthorityDescription;
parameters[3].Value = model.AuthorityOrder;
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论