zoukankan      html  css  js  c++  java
  • 使用Oledb传参数的悲剧,update返回永远是0条记录

    首先我承认.基础不牢靠.

     /// <summary>
            /// 设置系统设置
            /// </summary>
            /// <param name="key">键</param>
            /// <<param name="val">值得</param>
            /// <returns></returns>
            public int SetSystemConfig(string key, string val)
            {
                DbParameter[] parm = {
                                                
                                                DbHelper.MakeInParam("@val",(DbType)OleDbType.VarChar,50,val)
                                                ,DbHelper.MakeInParam("@key",(DbType)OleDbType.VarChar,50,key)

                                            };
                //OleDbConnection conn= new OleDbConnection(DbHelper.ConnectionString);
                //conn.Open();
                int result=0;
              
                    //    OleDbCommand cmd = conn.CreateCommand();
                       string sql =  "update [systemConfig] set [sysval]='"+ val +"' where [syskey]='"+ key +"'";
               // cmd.CommandText = sql;
                       result = DbHelper.ExecuteNonQuery(  CommandType.Text, @"update [systemConfig] set [sysval]=@val where syskey=@key", parm);
                       //  result = cmd.ExecuteNonQuery();
                 
              //  conn.Close();
               return result;
            }

    就是上面的那段传参数的.参数传入的位置必须和sql语句中船舷的先后顺序一致..

    在此之前,我臆想了我的操作系统与是window7 x64的原因?还是office2007的原因?或者access文件是2006年创建的?其实都不是...

  • 相关阅读:
    2019阿里系电子书合集来了!
    FTP主动模式和被动模式的区别
    Vsftpd运行的两种模式-xinetd运行模式和 standalone模式
    Logstash组件详解(input、codec、filter、output)
    Docker入门-笔记-1
    K8S命令-Kubectl 命令大全
    Nginx-HTTP Strict Transport Security(HSTS)
    IPV6技术笔记(剖析IPv4toIPv6)
    一个交换机到底能带几台摄像头?结合生产经验咱们来分析!
    ELK查询命令详解
  • 原文地址:https://www.cnblogs.com/jifsu/p/1678422.html
Copyright © 2011-2022 走看看