菜鸟请教VB中简单查询问题~~

一夜清懈 部门经理  2004-09-19 03:19:58
小弟初学VB!
我想查询两个日期之间的记录,在VB应该怎么做,SQL语句怎么写?
...全文
70 点赞 收藏 4
写回复
4 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
一夜清懈 2004-09-19
谢了
回复
RUKYO 2004-09-19
'vb、SQLServer的写法:

Option Explicit
Public mConnString As String

Private Sub Command1_Click()
Dim mRst As New ADODB.Recordset
mRst.CursorLocation = adUseClient
mRst.Open "Select * From 表111 Where 收费日期 Between '" & DTPicker1.Value & "' And '" & DTPicker2.Value & "'", mConnString, adOpenStatic, adLockOptimistic, adCmdText
MsgBox mRst.Fields(0)
End Sub

Private Sub Form_Load()
mConnString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=test;Data Source=server"
End Sub
回复
liuberlin 2004-09-19
用Between And 就可以了,
记得在ACCESS要用##括住日期
在SQL SERVER 中用‘’括住日期
回复
RUKYO 2004-09-19
Access:
Select * From YourTable Where DateField Between #2004-10-11# And #2004-12-12#

SQLServer:
Select * From YourTable Where DateField Between '2004-10-11' And '2004-12-12'
回复
相关推荐
发帖

1188

社区成员

VB 数据库(包含打印,安装,报表)
申请成为版主
帖子事件
创建了帖子
2004-09-19 03:19
社区公告
暂无公告