System.Data.SqlClient.SqlException: 必须声明标量变量 "@newId"
sqlhelper语句:publicDataTableExecuteQuery(stringsql,SqlParameter[]paras){DataTabledt=ne...
sqlhelper语句:
public DataTable ExecuteQuery(string sql, SqlParameter[] paras)
{
DataTable dt = new DataTable();
cmd = new SqlCommand(sql, GetConn());
cmd.Parameters.AddRange(paras);
using (sdr = cmd.ExecuteReader(CommandBehavior.CloseConnection))
{
dt.Load(sdr);
}
return dt;
}
DAO语句
public DataTable SelectByNewId(string newsId)
{
DataTable dt = new DataTable();
string sql = "select * from comment where newsId=@newId";
SqlParameter[] paras = new SqlParameter[] {
new SqlParameter("@newsId",newsId)
};
dt = sqlhelper.ExecuteQuery(sql, paras);
return dt;
} 展开
public DataTable ExecuteQuery(string sql, SqlParameter[] paras)
{
DataTable dt = new DataTable();
cmd = new SqlCommand(sql, GetConn());
cmd.Parameters.AddRange(paras);
using (sdr = cmd.ExecuteReader(CommandBehavior.CloseConnection))
{
dt.Load(sdr);
}
return dt;
}
DAO语句
public DataTable SelectByNewId(string newsId)
{
DataTable dt = new DataTable();
string sql = "select * from comment where newsId=@newId";
SqlParameter[] paras = new SqlParameter[] {
new SqlParameter("@newsId",newsId)
};
dt = sqlhelper.ExecuteQuery(sql, paras);
return dt;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询