Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What's Wrong Here
Message
General information
Forum:
Visual Basic
Category:
Database DAO/RDO/ODBC/ADO
Title:
What's Wrong Here
Miscellaneous
Thread ID:
00692553
Message ID:
00692553
Views:
54
I'm trying to access a VFP database:

I have a reference set to MS ADO 2.7. When I run this, RecordCount is -1
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 Sub
However, 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
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Next
Reply
Map
View

Click here to load this message in the networking platform