使用vb6从oracle数据库中检索当前日期记录
我有一张包含作品列表的表格。所以我想使用vb6在msflexgrid中显示今天的工作列表。
代码:
strwrlist = "Select * From BIOMED.HelpDesk_Work_Master where TO_DATE(TO_CHAR(WR_DATE,'DD-MON-YYYY HH:MM:SS'),'DD-MON-YYYY HH:MM:SS')='" & dt & "'"
'dt hold the current date i.e. dt = Format(CDate(rsgetdt.Fields("SYSDATE")), "DD-MMM-YYYY HH:MM:SS")
MsgBox strwrlist
Set rsgetwrlist = Nothing
If rsgetwrlist.State = adStateOpen Then rsgetwrlist.Close
rsgetwrlist.Open strwrlist, Cn.con, adOpenForwardOnly, adLockReadOnly
Do While Not rsgetwrlist.EOF
If IsNull(rsgetwrlist("WR_NO")) = False Then
msflxgrdlow.TextMatrix(r, 0) = rsgetwrlist.Fields("WR_NO")
End If
msflxgrdlow.AddItem ""
rsgetwrlist.MoveNext
r = r + 1
loop
但是当我从 vb 运行此查询时,它没有给我记录列表 当我在蟾蜍(oracle)中运行相同的查询时,它给出了工作列表。 那么确切的问题是什么?
I have one table that contains a list of works. So I want to display the today's work list in msflexgrid using vb6.
code:
strwrlist = "Select * From BIOMED.HelpDesk_Work_Master where TO_DATE(TO_CHAR(WR_DATE,'DD-MON-YYYY HH:MM:SS'),'DD-MON-YYYY HH:MM:SS')='" & dt & "'"
'dt hold the current date i.e. dt = Format(CDate(rsgetdt.Fields("SYSDATE")), "DD-MMM-YYYY HH:MM:SS")
MsgBox strwrlist
Set rsgetwrlist = Nothing
If rsgetwrlist.State = adStateOpen Then rsgetwrlist.Close
rsgetwrlist.Open strwrlist, Cn.con, adOpenForwardOnly, adLockReadOnly
Do While Not rsgetwrlist.EOF
If IsNull(rsgetwrlist("WR_NO")) = False Then
msflxgrdlow.TextMatrix(r, 0) = rsgetwrlist.Fields("WR_NO")
End If
msflxgrdlow.AddItem ""
rsgetwrlist.MoveNext
r = r + 1
loop
But it does not give me a list of records when I run this query from vb
and same query when I run in toad (oracle) it gives the list of work.
So what is the exact problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我预计其中一部分是您在日期比较的各种不同格式之间进行强制。
尝试一下:
确保 WR_DATE 和 dt 都是正确的日期类型(Oracle 中的 TIMESTAMP)。
这会保留并进行正确的日期转换和比较。
I expect part of it is you coersion between verious different formats for the date comparison.
Try just:
making sure that both WR_DATE and the dt are properly Date typed (TIMESTAMP in Oracle).
This preserves and does the proper date conversion and comparison.