obscure999
obscure999
2016-05-06 02:50

C# 必须声明标量变量 "@stu_gradewhere

5

代码和报错如下
DAL:///
//更新一条数据
///
public bool Update(Models.studentbm model)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("update student set ");
strSql.Append("stu_ID=@stu_ID,");
strSql.Append("stu_grade=@stu_grade,");
strSql.Append(" where stu_ID=@stu_ID");
SqlParameter[] parameters = {
new SqlParameter("@stu_ID", SqlDbType.VarChar,20),
new SqlParameter("@stu_grade", SqlDbType.VarChar,20)};

        parameters[0].Value = model.stu_ID;
        parameters[1].Value = model.stu_grade;
        int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        if (rows > 0)
        {
            return true;
        }
        else
        {
            return false;
        }
      }

BLL:
public int adminlr(string stu_ID,string stu_grade)
{
DAL.adminlrcj cj = new DAL.adminlrcj();
Models.studentbm lr = new Models.studentbm();
bool strper = false;
lr = cj.Getstudent(stu_ID);
if (lr != null)
{
lr.stu_grade = stu_grade;
strper = cj.Update(lr);
}
if (strper)
{
return Int32.Parse(stu_ID);
}
else
{
return 0;
}
图片说明

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答