您的位置:首页 > 其它

使用Oledb传参数的悲剧,update返回永远是0条记录

2010-03-04 16:25 399 查看
首先我承认.基础不牢靠.

/// <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年创建的?其实都不是...
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: