Dim rstTmp As New ADODB.Recordset
With rstTmp
Set .ActiveConnection = cnn
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.Open strSQL
End With
或者:
Dim rstTmp As New ADODB.Recordset
With rstTmp
.CursorLocation = adUseClient
.Open strSQL,cnn,adOpenDynamic
End With
Dim rstTmp As New ADODB.Recordset
With rstTmp
Set .ActiveConnection = cnn
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.Source = strSQL
.Open
End With
这样的写法有问题,主要是出现在.open上。我一般不这样写。
我一般这样写
dim rs as new adodb.recordset
dim cn as new adodb.connection
Dim rstTmp As New ADODB.Recordset
With rstTmp
Set .ActiveConnection = cnn
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.Source = strSQL
.Open
End With