Execute方法是来用执行一个命令,如Update,Insert,Delete等...而如果是用来查询,..最好是用Open方法来执行一个Select
例:.
Dim Conn As ADODB.Connection
Dim Rst As ADODB.Recordset
Dim ConString As String
Dim Sql As String
ConString = "Provider=Microsoft.Jet.OleDb.4.0;Data Source = D:\mdb\NorthWind.mdb"
Set Conn = CreateObject("ADODB.Connection")
Sql = "select * from Orders"
With Conn
.ConnectionString = ConString
.Open
End With
Set Rst = CreateObject("ADODB.Recordset")
With Rst
.LockType = adLockPessimistic
.CursorType = adOpenKeyset
.CursorLocation = adUseClient
.Open Sql, Conn, , , adCmdText
.MoveLast
.MoveFirst
End With
MsgBox "Success"
Rst.Close
Conn.Close