/// <summary>
/// 更新一条数据
/// </summary>
public bool Updateall(ZHLbookshop.Model.Vip model)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("update Vip set ");
strSql.Append("hylx_VipTypeId=@hylx_VipTypeId,");
strSql.Append("hy_Name=@hy_Name,");
strSql.Append("hy_Sex=@hy_Sex,");
strSql.Append("hy_Telephone=@hy_Telephone,");
strSql.Append("hy_Mobliephone=@hy_Mobliephone,");
strSql.Append("hy_QQ=@hy_QQ,");
strSql.Append("hy_Address=@hy_Address,");
strSql.Append("hy_PostCode=@hy_PostCode,");
strSql.Append("hy_Education=@hy_Education,");
//strSql.Append("hy_VipImage=@hy_VipImage");
strSql.Append(" where hy_VipId=@hy_VipId");
SqlParameter[] parameters = {
new SqlParameter("@hylx_VipTypeId", SqlDbType.Int,4),
new SqlParameter("@hy_Name", SqlDbType.VarChar,20),
new SqlParameter("@hy_Sex", SqlDbType.VarChar,2),
new SqlParameter("@hy_Telephone", SqlDbType.VarChar,20),
new SqlParameter("@hy_Mobliephone", SqlDbType.VarChar,20),
new SqlParameter("@hy_QQ", SqlDbType.VarChar,20),
new SqlParameter("@hy_Address", SqlDbType.VarChar,200),
new SqlParameter("@hy_PostCode", SqlDbType.VarChar,10),
new SqlParameter("@hy_Education", SqlDbType.VarChar,20),
// new SqlParameter("@hy_VipImage", SqlDbType.VarChar,100),
new SqlParameter("@hy_VipId", SqlDbType.Int,4)};
parameters[0].Value = model.hylx_VipTypeId;
parameters[1].Value = model.hy_Name;
parameters[2].Value = model.hy_Sex;
parameters[3].Value = model.hy_Telephone;
parameters[4].Value = model.hy_Mobliephone;
parameters[5].Value = model.hy_QQ;
parameters[6].Value = model.hy_Address;
parameters[7].Value = model.hy_PostCode;
parameters[8].Value = model.hy_Education;
//parameters[9].Value = model.hy_VipImage;
parameters[9].Value = model.hy_VipId; int rows = Common.DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
if (rows > 0)
{
return true;
}
else
{
return false;
}
}
这段代码是对表进行数据更新的,但没有要对hy_VipImage这个进行更新,如果注释起来会出现执行错误,不然的话hy_VipImage的值会被覆盖或者值为NULL
strSql.Append("hy_Education=@hy_Education");
strSql.ToString()
就知道是不是合法的sql语句; 了
这就多了个逗号了