asp.net中必须声明标量变量
在做注册的时候注册基本信息后 去注册详细信息 在同一个表里 然后执行修改操作 但是总是提示必须声明标量变量@AddDate
从网上找的解决方法 都不行 各位大侠帮帮忙吧 在线等 …………
public void Update(Farm.Model.Company model) { StringBuilder strSql=new StringBuilder(); strSql.Append("update Company set "); strSql.Append("GID=@GID,"); strSql.Append("CName=@CName,"); strSql.Append("CPwd=@CPwd,"); strSql.Append("TrueName=@TrueName,"); strSql.Append("CEmail=@CEmail,"); strSql.Append("CMobile=@CMobile,"); strSql.Append("Ctouch=@Ctouch,"); strSql.Append("CDes=@CDes,"); strSql.Append("Area=@Area,"); strSql.Append("Business=@Business,"); strSql.Append("IsValid=@IsValid,"); strSql.Append("AddDate=@AddDate"); strSql.Append("CType=@CType"); strSql.Append("CDate=@CDate"); strSql.Append("Service=@Service"); strSql.Append("CFace=@CFace"); strSql.Append(" where CID=@CID "); SqlParameter[] parameters = { new SqlParameter("@CID", SqlDbType.Int,4), new SqlParameter("@GID", SqlDbType.Int,4), new SqlParameter("@CName", SqlDbType.VarChar,50), new SqlParameter("@CPwd", SqlDbType.VarChar,50), new SqlParameter("@TrueName", SqlDbType.VarChar,50), new SqlParameter("@CEmail", SqlDbType.VarChar,50), new SqlParameter("@CMobile", SqlDbType.VarChar,50), new SqlParameter("@Ctouch", SqlDbType.VarChar,50), new SqlParameter("@CDes", SqlDbType.Text), new SqlParameter("@Area", SqlDbType.VarChar,100), new SqlParameter("@Business", SqlDbType.VarChar,200), new SqlParameter("@IsValid", SqlDbType.Int,4), new SqlParameter("@AddDate", SqlDbType.DateTime), new SqlParameter("@CType",SqlDbType.VarChar,50), new SqlParameter("@CDate",SqlDbType.DateTime), new SqlParameter("@Service",SqlDbType.Text), new SqlParameter("@CFace",SqlDbType.VarChar,50)}; parameters[0].Value = model.CID; parameters[1].Value = model.GID; parameters[2].Value = model.CName; parameters[3].Value = model.CPwd; parameters[4].Value = model.TrueName; parameters[5].Value = model.CEmail; parameters[6].Value = model.CMobile; parameters[7].Value = model.Ctouch; parameters[8].Value = model.CDes; parameters[9].Value = model.Area; parameters[10].Value = model.Business; parameters[11].Value = model.IsValid; parameters[12].Value = model.AddDate; parameters[13].Value = model.Ctype; parameters[14].Value = model.Cdate; parameters[15].Value = model.Service; parameters[16].Value = model.Cface; Farm.DBUtility.DbHelperSQL.ExecuteSql(strSql.ToString(),parameters); }
strSql.Append("update Company set ");
strSql.Append("GID=@GID,");
strSql.Append("CName=@CName,");
strSql.Append("CPwd=@CPwd,");
strSql.Append("TrueName=@TrueName,");
strSql.Append("CEmail=@CEmail,");
strSql.Append("CMobile=@CMobile,");
strSql.Append("Ctouch=@Ctouch,");
strSql.Append("CDes=@CDes,");
strSql.Append("Area=@Area,");
strSql.Append("Business=@Business,");
strSql.Append("IsValid=@IsValid,");
strSql.Append("AddDate=@AddDate,");
strSql.Append("CType=@CType,");
strSql.Append("CDate=@CDate,");
strSql.Append("Service=@Service,");
strSql.Append("CFace=@CFace");
strSql.Append(" where CID=@CID ");
后面加 逗号
[解决办法]