首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

asp.net中必须声明标量变量解决思路

2012-04-21 
asp.net中必须声明标量变量在做注册的时候注册基本信息后 去注册详细信息 在同一个表里 然后执行修改操作

asp.net中必须声明标量变量
在做注册的时候注册基本信息后 去注册详细信息 在同一个表里 然后执行修改操作 但是总是提示必须声明标量变量@AddDate
从网上找的解决方法 都不行 各位大侠帮帮忙吧 在线等 …………

C# code
    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("AddDate=@AddDate,");
strSql.Append("CType=@CType,");
strSql.Append("CDate=@CDate,");
strSql.Append("Service=@Service,");
[解决办法]
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 ");


后面加 逗号
[解决办法]

探讨
strSql.Append("AddDate=@AddDate,");
strSql.Append("CType=@CType,");
strSql.Append("CDate=@CDate,");
strSql.Append("Service=@Service,");

[解决办法]
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 ");


后面加 逗号

热点排行