C# 必须声明标量变量 "@stu_gradewhere
代码和报错如下DAL:///<summary>//更新一条数据///<summary>publicboolUpdate(Models.studentbmmodel){St...
代码和报错如下
DAL:/// <summary>
//更新一条数据
/// <summary>
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;
} 展开
DAL:/// <summary>
//更新一条数据
/// <summary>
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;
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询