用VB+ADO查询日期条件则无法返回正常结果?急急急!!!高手请进!在线等待....

thankyourfish 2003-10-18 11:38:53
我用的是access+ADO,运行如下查询时:
select * from depositorInfo where 姓名='& username &' and (日期 between #"& dateStart &"# and #"& dateEnd &")
  出现错误提示:
    No Value given for one or more required parameters
请高手指点帮忙!急急急



...全文
35 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
mingtian2008 2003-10-27
  • 打赏
  • 举报
回复
我当时 是这样做的
我把Access的时间定义为“文本”
在我查询的时候 你可以用 like去查他呀 ? 你可以在时间的前或是后加上 %
select * from depositorInfo where 姓名='"& username &"' and (日期 like '%"& date & "%')
我的方法不是很好 你看看吧 我也想 不把时间定义成文本 当时为了 把程序给做出来就 改了/
hqsee 2003-10-27
  • 打赏
  • 举报
回复
datediff(dd,[date],'2003-10-27')>=0
thankyourfish 2003-10-23
  • 打赏
  • 举报
回复
我已经解决了,实际上只要在变量前加上日期格式化即可以。如:format(DateStart,"mm/dd/yyyy")。谢谢各位了。
j4sxw 2003-10-20
  • 打赏
  • 举报
回复
select * from depositorInfo where 姓名='& username &' and 日期 between #"& dateStart &"# and #"& dateEnd &"
括号去掉试试看
或者用

select * from depositorInfo where 姓名='& username &' and 日期 >= #"& dateStart &"# and 日期 <=#"& dateEnd &"#
BraveHorse 2003-10-20
  • 打赏
  • 举报
回复
up
trendvb 2003-10-20
  • 打赏
  • 举报
回复
少了一个#号最后.
如果是SQLSERVER,应用"'".肯定没问题你的语句没错.
照我的法子.
sword281 2003-10-20
  • 打赏
  • 举报
回复
使用大于和小于符号不要用between,and(它们是集合)但它不知道在datastart,dataend间的数据
liaorui 2003-10-20
  • 打赏
  • 举报
回复
用debug.print 把你这条SQL打出来,然后拿到ACCESS里运行一下,看一下错误在那里!
luzufu 2003-10-20
  • 打赏
  • 举报
回复
select * from depositorInfo where 姓名='"& username &"' and (convert(char(10),日期,120)>="& dateStart &" and convert(char(10),日期,120)<="& dateEnd & ")"
ywh1101 2003-10-19
  • 打赏
  • 举报
回复
三个变量,你确定都赋值了?

用日期>=datestart and 日期<=dateend不行码?
itlive 2003-10-19
  • 打赏
  • 举报
回复
试一试这样写何如
"select * from depositorInfo where 姓名='"& username &"' and (日期 between #"& dateStart &"# and #"& dateEnd &"#")
thankyourfish 2003-10-19
  • 打赏
  • 举报
回复
我试了仍然不行啊,怎么办?
thankyourfish 2003-10-19
  • 打赏
  • 举报
回复
是不是将时间转换成“mm/dd/yy”形式,我试试,谢谢啦
海牛 2003-10-19
  • 打赏
  • 举报
回复
'试一试^_^
select * from depositorInfo where 姓名='& username &' and (DateDiff('d',日期,dateStart)<=0 And (DateDiff('d',日期,dateEnd )>=0)
changechange 2003-10-19
  • 打赏
  • 举报
回复
你直接把date数据类型放进去了?
myhot-河马吃草 2003-10-19
  • 打赏
  • 举报
回复
用日期>=#" & fomrat(datestart,"yyyy-mm-dd") &"# and 日期<=>=#" & fomrat(dateend,"yyyy-mm-dd") &"# "
hemeijun81 2003-10-19
  • 打赏
  • 举报
回复
用format 把时间转换过来

1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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