Option Explicit Public oConn As ADODB.Connection Public oSqlCmd As ADODB.Command Public Sub Main() Set oConn = New ADODB.Connection oConn.Open "Provider=vfpoledb.1;Data Source=D:\Projects\Visual Basic\AppLoader\Data\AppLoader.DBC" Set oSqlCmd = New ADODB.Command With oSqlCmd .ActiveConnection = oConn .CommandType = adCmdText .CommandText = "select * from components" End With Set oRecSet = New ADODB.Recordset Set oRecSet = oSqlCmd.Execute MsgBox oRecSet.RecordCount End SubHowever, this works:
' Create a record set Set oRecSet = New ADODB.Recordset With oRecSet ' Assign the record set properties .ActiveConnection = oConn .CursorType = adOpenKeyset .LockType = adLockOptimistic .CursorLocation = adUseServer ' Open the record set .Open sTableName End With