关于分页查询语句的问题......

OberPan 2009-07-20 01:46:12
我是刚学Access,不足之处,请各位大虾指教!!!
public DataSet getPagedInfo(string tbName, int index, int count, out int rowCount)
{
string sql = "select top " + count + " * from " + tbName + " where [ID] not in (select top " + index * count + " [ID] from " + tbName + ")";

OleDbConnection mconCurrent = GetConn();
DataSet ds = new DataSet();
mconCurrent.Open();
int res = 0;
rowCount = getInfoCount(tbName);//这里可以拿到查询表的总记录数
try
{
OleDbDataAdapter oleDt = new OleDbDataAdapter(sql, mconCurrent);
oleDt.Fill(ds);
return ds;
}
finally { closeConn(mconCurrent); }
}

程序运行传入的参数 (JobInfo,0,4,out rCount) 生成语句select top 4 * from JobInfo where [ID] not in (select top 0 [ID] from JobInfo);在运行到oleDt.Fill(ds);这句时程序报错:【System.Data.OleDb.OleDbException: 语法错误。 在查询表达式 '[ID] not in (select top 0 [ID] from JobInfo)' 中】,但是我在sql server里面可以运行这个语句,这到底是什么原因???
...全文
16 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
OberPan 2009-07-20
  • 打赏
  • 举报
回复
谢啦
ACMAIN_CHM 2009-07-20
  • 打赏
  • 举报
回复
ACCESS中使用的是JET-SQL不是MS SQL SERVER中的T-SQL。

在JET-SQL中 select top n, 这个N必须大于0


当您的问题得到解答后请及时结贴.
http://topic.csdn.net/u/20090501/15/7548d251-aec2-4975-a9bf-ca09a5551ba5.html

7,714

社区成员

发帖
与我相关
我的任务
社区描述
Microsoft Office Access是由微软发布的关系数据库管理系统。它结合了 MicrosoftJet Database Engine 和 图形用户界面两项特点。
社区管理员
  • Access
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧