string cmdText = "insert into Survey (Address,Jiekuan,Work,Workplace,position,LoanBalance,LoanTerm,LoanWay,LoanKind,LoanUses,RepaymentDay,RepaymentWay,Contact,BasicInfo,OtherInfo) values(@Address,@Jiekuan,@Work,@Workplace,@position,@LoanBalance,@LoanTerm,@LoanWay,@LoanKind,@LoanUses,@RepaymentDay,@RepaymentWay,@Contact,@BasicInfo,@OtherInfo )"; SqlParameter[] param = new SqlParameter[]{
new SqlParameter("@Address","@Jiekuan","@Work","@Workplace","@position","@LoanBalance","@LoanTerm","@LoanWay","@LoanKind","@LoanUses","@RepaymentDay","@RepaymentWay","@Contact","@BasicInfo","@OtherInfo",survey.Address,survey.Jiekuan,survey.Work,survey.Workplace,survey.position,survey.LoanBalance,survey.LoanTerm,survey.LoanWay,survey.LoanKind,survey.LoanUses,survey.RepaymentDay,survey.RepaymentWay,survey.Contact,survey.BasicInfo,survey.OtherInfo)
};
SQLHelper.ExecuteNonQuery(SQLHelper.connString, CommandType.Text, cmdText, param);
return 0;
错误 7 “SqlParameter”方法没有采用“30”个参数的重载 C:\Documents and Settings\Administrator\桌面\新建文件夹\XQLoan\SQLServerDal\SurveyDal.cs 22 17 SQLServerDal
错误 7 “SqlParameter”方法没有采用“30”个参数的重载 C:\Documents and Settings\Administrator\桌面\新建文件夹\XQLoan\SQLServerDal\SurveyDal.cs 22 17 SQLServerDal
new SqlParameter("@Address","@Jiekuan","@Work","@Workplace","@position","@LoanBalance","@LoanTerm","@LoanWay","@LoanKind","@LoanUses","@RepaymentDay","@RepaymentWay","@Contact","@BasicInfo","@OtherInfo",survey.Address,survey.Jiekuan,survey.Work,survey.Workplace,survey.position,survey.LoanBalance,survey.LoanTerm,survey.LoanWay,survey.LoanKind,survey.LoanUses,survey.RepaymentDay,survey.RepaymentWay,survey.Contact,survey.BasicInfo,survey.OtherInfo)
};
SQLHelper.ExecuteNonQuery(SQLHelper.connString, CommandType.Text, cmdText, param);
return 0;
错误 7 “SqlParameter”方法没有采用“30”个参数的重载 C:\Documents and Settings\Administrator\桌面\新建文件夹\XQLoan\SQLServerDal\SurveyDal.cs 22 17 SQLServerDal
错误 7 “SqlParameter”方法没有采用“30”个参数的重载 C:\Documents and Settings\Administrator\桌面\新建文件夹\XQLoan\SQLServerDal\SurveyDal.cs 22 17 SQLServerDal
b2bDatabase.AddInParameter(dbCommand, "HeaderID", DbType.Int32, order.HeaderID );
...
}
protected void Button1_Click(object sender, EventArgs e)
{
Model.Survey s = new Model.Survey();
s.Jiekuan = Convert.ToInt16(this.txtjiekuanren.Text);
s.Address = this.txtAdd.Text;
s.Work = this.TxtWork.Text;
s.Workplace = this.txtWorkPlace.Text;
s.position = this.txtPosition.Text;
s.LoanBalance = Convert.ToDecimal(this.txtLoanBalance.Text);
s.LoanTerm = this.txtLoanTerm.Text;
s.LoanWay = this.txtLoanWay.Text;
s.LoanKind = this.txtLoanKind.Text;
s.LoanUses = this.TxtLoanUses.Text;
s.RepaymentDay = Convert.ToDateTime(this.txtRepaymentDay.Text);
s.RepaymentWay = this.txtRepaymentWay.Text;
s.Contact = this.txtContact.Text;
s.BasicInfo = this.TxtBasicInfo.Text;
s.OtherInfo = this.txtOtherInfo.Text;
s.FinanceInfo = this.TxtFinanceInfo.Text;
s.Opinion = this.txtOpinion.Text;
s.opinionDay = Convert.ToDateTime(this.txtOpinionDay.Text); BLL.SurveyBLL.Add(s);}
这样一个一个的写
你也可以写一个方法接收SqlParameter[]
你那样写显然是不对的。
SqlParameter[] param = {
new SqlParameter("@Address",SqlDbType.NVarChar,100),
new SqlParameter("@Jiekuan",SqlDbType.NVarChar,100),
...
}
param[0].value=...;
param[1].value=...;
...
cmd.Parameters.Add(param[0]);
...好象这样。
现在改成这样
public int Add(Survey survey)
{
string cmdText = "insert into Survey (Address,Jiekuan,Work,Workplace,position,LoanBalance,LoanTerm,LoanWay,LoanKind,LoanUses,RepaymentDay,RepaymentWay,Contact,BasicInfo,OtherInfo) values(@Address,@Jiekuan,@Work,@Workplace,@position,@LoanBalance,@LoanTerm,@LoanWay,@LoanKind,@LoanUses,@RepaymentDay,@RepaymentWay,@Contact,@BasicInfo,@OtherInfo )";
SqlParameter[] param = { new SqlParameter("@Address",SqlDbType.NVarChar,100,survey.Address),
new SqlParameter("@Jiekuan",SqlDbType.NVarChar,100,survey.Jiekuan),
new SqlParameter("@Work",SqlDbType.NVarChar,100,survey.Work),
new SqlParameter("@Workplace",SqlDbType.NVarChar,100,survey.Workplace),
new SqlParameter("@Position",SqlDbType.NVarChar,100),
new SqlParameter("@LoanBlalance",SqlDbType.NVarChar,100),
new SqlParameter("@LoanTerm",SqlDbType.NVarChar,100),
new SqlParameter("@LoanWay",SqlDbType.NVarChar,100),
new SqlParameter("@LoanKind",SqlDbType.NVarChar,100),
new SqlParameter("@LoanUses",SqlDbType.NVarChar,100),
new SqlParameter("@RepaymentDay",SqlDbType.NVarChar,100),
new SqlParameter("@RepaymentWay",SqlDbType.NVarChar,100),
new SqlParameter("@Contact",SqlDbType.NVarChar,100),
new SqlParameter("@BasicInfo",SqlDbType.NVarChar,100),
new SqlParameter("@OtherInfo",SqlDbType.NVarChar,100), };
SQLHelper.ExecuteNonQuery(SQLHelper.connString, CommandType.Text, cmdText, param);
return 0;
//FinanceInfo text, ----财务情况
//Opinion text, ----审核意见
//opinionDay datetime ----审核日期
}
public int Add(Survey survey)
{
string cmdText = "insert into Survey (Address,Jiekuan,Work,Workplace,position,LoanBalance,LoanTerm,LoanWay,LoanKind,LoanUses,RepaymentDay,RepaymentWay,Contact,BasicInfo,OtherInfo) values(@Address,@Jiekuan,@Work,@Workplace,@position,@LoanBalance,@LoanTerm,@LoanWay,@LoanKind,@LoanUses,@RepaymentDay,@RepaymentWay,@Contact,@BasicInfo,@OtherInfo )";
SqlParameter[] param = { new SqlParameter("@Address",SqlDbType.NVarChar,100),
new SqlParameter("@Jiekuan",SqlDbType.NVarChar,100),
new SqlParameter("@Work",SqlDbType.NVarChar,100),
new SqlParameter("@Workplace",SqlDbType.NVarChar,100),
new SqlParameter("@Position",SqlDbType.NVarChar,100),
new SqlParamete("@LoanBlalance",SqlDbType.NVarChar,100),
new SqlParameter("@LoanTerm",SqlDbType.NVarChar,100),
new SqlParameter("@LoanWay",SqlDbType.NVarChar,100),
new SqlParameter("@LoanKind",SqlDbType.NVarChar,100),
new SqlParameter("@LoanUses",SqlDbType.NVarChar,100),
new SqlParameter("@RepaymentDay",SqlDbType.NVarChar,100),
new SqlParameter("@RepaymentWay",SqlDbType.NVarChar,100),
new SqlParameter("@Contact",SqlDbType.NVarChar,100),
new SqlParameter("@BasicInfo",SqlDbType.NVarChar,100),
new SqlParameter("@OtherInfo",SqlDbType.NVarChar,100)
};
param[0].value=survey.Address;
param[1].value=survey.Jiekuan;
param[2].value=survey.Work;
param[3].value=survey.Workplace;
....
你的字段类型都是nvarchar(100)的吗?
SqlDbType可以.出好多类型..
{
public class SurveyDal : ISurvey
{ /// <summary>
/// 增加一条数据
/// </summary>
public int Add(Survey survey)
{
string cmdText = "insert into Survey (Address,Jiekuan,Work,Workplace,position,LoanBalance,LoanTerm,LoanWay,LoanKind,LoanUses,RepaymentDay,RepaymentWay,Contact,BasicInfo,OtherInfo) values(@Address,@Jiekuan,@Work,@Workplace,@position,@LoanBalance,@LoanTerm,@LoanWay,@LoanKind,@LoanUses,@RepaymentDay,@RepaymentWay,@Contact,@BasicInfo,@OtherInfo )";
SqlParameter[] param = { new SqlParameter("@Address",SqlDbType.NVarChar,100,survey.Address),
new SqlParameter("@Jiekuan",SqlDbType.NVarChar,100,survey.Jiekuan),
new SqlParameter("@Work",SqlDbType.NVarChar,100,survey.Work),
new SqlParameter("@Workplace",SqlDbType.NVarChar,100,survey.Workplace),
new SqlParameter("@Position",SqlDbType.NVarChar,100),
new SqlParameter("@LoanBlalance",SqlDbType.NVarChar,100),
new SqlParameter("@LoanTerm",SqlDbType.NVarChar,100),
new SqlParameter("@LoanWay",SqlDbType.NVarChar,100),
new SqlParameter("@LoanKind",SqlDbType.NVarChar,100),
new SqlParameter("@LoanUses",SqlDbType.NVarChar,100),
new SqlParameter("@RepaymentDay",SqlDbType.NVarChar,100),
new SqlParameter("@RepaymentWay",SqlDbType.NVarChar,100),
new SqlParameter("@Contact",SqlDbType.NVarChar,100),
new SqlParameter("@BasicInfo",SqlDbType.NVarChar,100),
new SqlParameter("@OtherInfo",SqlDbType.NVarChar,100), };
param[0].value = survey.Address;
param[1].value = survey.Jiekuan;
param[2].value = survey.Work;
param[3].value = survey.Workplace;
SQLHelper.ExecuteNonQuery(SQLHelper.connString, CommandType.Text, cmdText, param);
return 0;
//FinanceInfo text, ----财务情况
//Opinion text, ----审核意见
//opinionDay datetime ----审核日期
} /// <summary>
/// 得到一个对象实体
/// </summary>
改成这样 还是不可以
仔细检查存储过程、dal层、bll层以及前端使用,基本就可以找到了
下面没有了?
param[4].value = survey.....//继续写了没?
还有上面sqlHelper操作类都没有存在了?你添加引用了吧?
SQLHelper.ExecuteNonQuery(SQLHelper.connString, CommandType.Text, cmdText, param);
return 0;这样可以吗???不懂 晕