使用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年创建的?其实都不是...

原文地址:https://www.cnblogs.com/jifsu/p/1678422.html