语法错误 (操作符丢失) 在查询表达式
/// <summary>
/// 产品分页展示
/// </summary>
/// <param name="pagesize">每页显示多少条</param>
/// <param name="pageindex">当前第几页</param>
/// <returns></returns>
public List<prod_news> ProductFenYe(int begin, int end)
{
try
{
string sqlStr = "select*from(select row_number()over(order by infotime desc)as RowIndex,*from prod_news)as a where RowIndex between "+begin+" and "+end;
OleDbCommand cmd = new OleDbCommand(sqlStr, con);
OleDbParameter par1 = new OleDbParameter("@begin",OleDbType.Integer);
OleDbParameter par2 = new OleDbParameter("@end",OleDbType.Integer);
par1.Value = begin;
par2.Value = end;
cmd.Parameters.Add(par1);
cmd.Parameters.Add(par2);
List<prod_news> list = new List<prod_news>();
con.Open();
OleDbDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
prod_news prod_news = new prod_news();
prod_news.ID = Convert.ToInt32(reader["ID"]);
prod_news.title = reader["title"].ToString();
prod_news.content = reader["content"].ToString();
prod_news.ClassName = reader["ClassName"].ToString();
prod_news.img = reader["img"].ToString();
prod_news.okay2 = Convert.ToInt32(reader["okay2"]);
prod_news.okay = Convert.ToInt32(reader["okay"]);
prod_news.infotime = Convert.ToDateTime(reader["infotime"]);
prod_news.hits = Convert.ToInt32(reader["hits"]);
prod_news.ok = Convert.ToBoolean(reader["ok"]);
list.Add(prod_news);
}
return list;
}
catch (Exception ec)
{
throw ec;
}
连接的是ACCESS数据库 老提示语法错误 (操作符丢失) 在查询表达式 'row_number()over(order by infotime desc)' 中。 如果是SQL server就没事啊 谁帮解决 谢谢
[解决办法]
把你的sql发到sqlserver专区里面去,可能效果会更好一点。