写了一个方法,总是提示:必须声明标量变量 "@ID"。 哪位大侠知道,请帮帮忙吧,不胜感激!
publicDataTableSelectTopNews(intID){stringstrsql="selecttop1*fromNewswhereID=@ID";Sql...
public DataTable SelectTopNews(int ID)
{
string strsql = "select top 1 * from News where ID=@ID";
SqlParameter[] para = new SqlParameter[]
{
new SqlParameter("@ID",ID)
};
return SqlHelper.ExecuteDataSet(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strsql, null).Tables[0];
} 展开
{
string strsql = "select top 1 * from News where ID=@ID";
SqlParameter[] para = new SqlParameter[]
{
new SqlParameter("@ID",ID)
};
return SqlHelper.ExecuteDataSet(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strsql, null).Tables[0];
} 展开
1个回答
展开全部
用最简单方式试试:
public DataTable SelectTopNews(int ID)
{
string strsql = "select top 1 * from News where ID="+ID;
return SqlHelper.ExecuteDataSet(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strsql, null).Tables[0];
}
public DataTable SelectTopNews(int ID)
{
string strsql = "select top 1 * from News where ID="+ID;
return SqlHelper.ExecuteDataSet(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strsql, null).Tables[0];
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询