参数查询的疑问,高手请进

aykkk 2011-09-26 04:50:03
sql语句如下:
select * from CompHonor where id in(@ids)
说明,id是自动编号类型,上述语句中没有返回记录,如果把@ids替换成23,24,25或者是单个数值则是可以返回正确结果的,无论程序中,还是access中,都是这个现象,请问怎么解决这个问题
我程序中是这么写的
string strsql = "select * from CompHonor where id in (@ids)";
OleDbParameter[] parms = { new OleDbParameter("@ids", ids) };
...全文
53 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
aykkk 2011-09-27
  • 打赏
  • 举报
回复
换成"?"也不行的。只要不是单个值就查不到任何记录。另外我发现,access也是可以使用命名参数的,不一定非要用"?"。
ACMAIN_CHM 2011-09-26
  • 打赏
  • 举报
回复
string strsql = "select * from CompHonor where id in (?)";
OleDbParameter[] parms = { new OleDbParameter("?", ids) };
wwwwb 2011-09-26
  • 打赏
  • 举报
回复
string strsql = "select * from CompHonor where id in (@ids)";
OleDbParameter[] parms = { new OleDbParameter("@ids", ids) };

检查一下strsql中的内容
aykkk 2011-09-26
  • 打赏
  • 举报
回复
果然可以,请问这是什么原因呢?
wwwwb 2011-09-26
  • 打赏
  • 举报
回复
string strsql = "select * from CompHonor where id in ("+@ids+")";
再执行

7,714

社区成员

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

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