zoukankan      html  css  js  c++  java
  • Access UPdate 标准表达式中数据类型不匹配

    一直没机会用ASP.NET操作ACCESS数据库,今天一用就让我遇到一个很奇怪的问题

    在UPdate操作时遇到一个"标准表达式中数据类型不匹配"错误~到现在我也没搞明是什么原因,添加,删除,查询都没问题,就只有在更新操作时会有问题,我尝试了一下将ID直接写到字符串中,不通过参数,这样就成功了

    问题代码:

    StringBuilder strSql = new StringBuilder();
                strSql.Append("update RGP_AuthorityDir set ");
                strSql.Append("AuthorityName=@AuthorityName,");
                strSql.Append("AuthorityTag=@AuthorityTag,");
                strSql.Append("AuthorityDescription=@AuthorityDescription,");
                strSql.Append("AuthorityOrder=@AuthorityOrder");
                strSql.Append(" where AuthorityID=@AuthorityID ");
                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();
                strSql.Append("update RGP_AuthorityDir set ");
                strSql.Append("AuthorityName=@AuthorityName,");
                strSql.Append("AuthorityTag=@AuthorityTag,");
                strSql.Append("AuthorityDescription=@AuthorityDescription,");
                strSql.Append("AuthorityOrder=@AuthorityOrder");
                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;   

  • 相关阅读:
    Representation Data in OpenCascade BRep
    Render OpenCascade Geometry Surfaces in OpenSceneGraph
    Render OpenCascade Geometry Curves in OpenSceneGraph
    OpenCascade Shape Representation in OpenSceneGraph
    Geometry Surface of OpenCascade BRep
    Geometry Curve of OpenCascade BRep
    Tyvj2017清北冬令营入学测试
    Spfa算法模板
    洛谷1016 旅行家的预算
    洛谷1290 欧几里得的游戏
  • 原文地址:https://www.cnblogs.com/nick4/p/1360437.html
Copyright © 2011-2022 走看看