在查询我的数据库中 5分钟数据表里数据时存在找不到记录的情况 而事实那条记录是存在的代码如下: Dim bDate As Date
CommandString = "5分钟数据"
bDate = #7/3/2009 2:45:00 PM# Adodc1.ConnectionString ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\data.mdb;Persist Security Info=False"
Adodc1.RecordSource = "select * from " & CommandString & " where 日期时间= #" & bDate & "# "
Adodc1.Refresh
a = Adodc1.Recordset.RecordCountbDate的时间是表中存在的 但是a=0
表中每隔5分钟有一条记录,其中有的能够查到 有的查不到 不知道是怎么回事。哪位高手能指导一下呢,谢谢
CommandString = "5分钟数据"
bDate = #7/3/2009 2:45:00 PM# Adodc1.ConnectionString ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\data.mdb;Persist Security Info=False"
Adodc1.RecordSource = "select * from " & CommandString & " where 日期时间= #" & bDate & "# "
Adodc1.Refresh
a = Adodc1.Recordset.RecordCountbDate的时间是表中存在的 但是a=0
表中每隔5分钟有一条记录,其中有的能够查到 有的查不到 不知道是怎么回事。哪位高手能指导一下呢,谢谢
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'函数功能:连接指定的数据库
'参数说明:cnnP:数据库连接对象;
' :adoP:数据集存储对象;
' :strPath:数据库路径;
' :strPassword:数据库密码;
'返回说明:True:连接成功 False:连接失败
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Public Function funConnectDataBase(cnnP As ADODB.Connection, adoP As ADODB.Recordset, ByVal strPath As _
String, ByVal strPassword As String) As Boolean
On Error GoTo errFunction
Set cnnP = New ADODB.Connection
Set adoP = New ADODB.Recordset
cnnP.Provider = "Microsoft.Jet.OLEDB.4.0"
cnnP.Open "Data Source = " & strPath & ";jet oledb:database password=" & strPassword
funConnectDataBase = True
Exit Function
errFunction:
funConnectDataBase = False
End Function
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'函数功能:关闭数据库连接对象和数据文件的关联
'参数说明:cnnP:数据库连接对象;
' :adoP:数据库存储对象;
'返回说明:True:关闭连接成功 False:关闭连接失败
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Public Function funCloseDataBase(cnnP As ADODB.Connection, adoP As ADODB.Recordset) As Boolean
On Error GoTo errFunction
Set adoP = Nothing
Set cnnP = Nothing
funCloseDataBase = True
Exit Function
errFunction:
funCloseDataBase = False
End Function
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'过程功能:对指定的对象执行指定的SQL语句
'参数说明:cnnP:ADO连接对象
' :adoP:ADO记录集对象
' :strSql:SQL语句
' :bolQueryRecord:是否是查询记录集
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Public Sub subExcuteSQL(cnnP As ADODB.Connection, adoP As ADODB.Recordset, strSql As String, bolQueryRecord _
As Boolean)
If bolQueryRecord Then '如果是查询记录集
adoP.Open strSql, cnnP, adOpenStatic, adLockBatchOptimistic
Else
cnnP.Execute strSql
End If
End Sub
(在ACCESS2003中通过调试)
Dim bDate As Date
CommandString = "5分钟数据"
bDate = #7/3/2009 2:45:01 PM#
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\data.mdb;Persist Security Info=False"
Adodc1.RecordSource = "select * from " & CommandString & " where 日期时间 between #" & bDate & "# And #" & bDate & "#"
Adodc1.Refresh
a = Adodc1.Recordset.RecordCount