高手请进,关于ADODB?
程序如下:
Public adocn As New ADODB.Connection
Public adors As New ADODB.Recordset
Public adocmd As New ADODB.Command
adocn.ConnectionString = "DSN=hys;DATABASE=hys "
adocn.Open
With adors
If .State = 1 Then .Close
Set adocmd.ActiveConnection = adocn
adocmd.CommandText = "Select * from djqsr where 生产日期 &_ between DTPicker1.Value and DTPicker2.Value
'DTPicker1和DTPicker2控件用于接受日期
.CursorLocation = adUseClient
.Open adocmd.CommandText, adocn, adOpenDynamic,&_ adLockBatchOptimistic, 2
End With
请高手赐教,请给出修改后的代码!定重谢!
[解决办法]
access数据库的日期格式是要用 “#”号的,如果上面的不行,试试这样改:
adocmd.CommandText = "Select * from djqsr where 生产日期 between '# "+ DTPicker1.Value + "# ' and '# " + DTPicker2.Value + "# ' "
[解决办法]
adocmd.CommandText = "Select * from djqsr where 生产日期 between '# " & DTPicker1.Value & "# ' and '# " & DTPicker2.Value & "# ' "
用了#就把单引号去掉才正确,改成下面的代码包你OK.
adocmd.CommandText = "Select * from djqsr where 生产日期 between # " & DTPicker1.Value & "# and # " & DTPicker2.Value & "# "
[解决办法]
就是你的帐号密码