VB sql 标准表达式中数据类型不匹配
Subtest()DimcnnAsNewADODB.ConnectionDimrsAsNewADODB.RecordsetDimsqlAsStringDimmybookA...
Sub test()
Dim cnn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim sql As String
Dim mybook As String
mybook = ThisWorkbook.FullName
With cnn
.Provider = "microsoft.jet.oledb.4.0"
.ConnectionString = "extended properties=""excel 8.0;HDR=YES;"";data source=" & mybook
.Open
End With
sql = "select * from [数据源$a2:c] where 检查时间-" & Date & ">60"
rs.Open sql, cnn, adOpenKeyset, adLockOptimistic
Worksheets("sheet1").Range("a1").CopyFromRecordset rs
End Sub
提示rs.Open sql, cnn, adOpenKeyset, adLockOptimistic标准表达式中数据类型不匹配 展开
Dim cnn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim sql As String
Dim mybook As String
mybook = ThisWorkbook.FullName
With cnn
.Provider = "microsoft.jet.oledb.4.0"
.ConnectionString = "extended properties=""excel 8.0;HDR=YES;"";data source=" & mybook
.Open
End With
sql = "select * from [数据源$a2:c] where 检查时间-" & Date & ">60"
rs.Open sql, cnn, adOpenKeyset, adLockOptimistic
Worksheets("sheet1").Range("a1").CopyFromRecordset rs
End Sub
提示rs.Open sql, cnn, adOpenKeyset, adLockOptimistic标准表达式中数据类型不匹配 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |