I have struggled for a number of days trying to get ADO to work
correctly (using VB to access FoxPro tables). The short
procedure that follows should illustrate the problems. I am using
ADO 2.0, VB 6.0, DBC and DBFs created in VFP6.0. The
database (for now) is on my local hard disk drive.
------------------------------------------------------------------------
------------
PROBLEM ONE:
When CURSORLOCATION is set to adUseClient (1),
any attempt to MOVEFIRST or MOVELAST causes the
following run-time error:
-2147467259 (80004005)
The data provider or other service returned an E-FAIL status.
Obviously not acceptable.
------------------------------------------------------------------------
------------
PROBLEM TWO:
When CURSORLOCATION is set to adUseServer (2),
MOVEFIRST and MOVELAST work correctly. However,
now the APPROXIMATE POSITIONING is no longer supported.
The ABSOLUTEPOSTION property is required to allow navigating
the database using a scrollbar.
------------------------------------------------------------------------
-------------------------------
THE CODE:
Private Sub Form_Activate()
Dim Conn As Connection
Dim rs As New Recordset
' create connection and SQL strings
ConnectString = "DRIVER=Microsoft Visual FoxPro Driver;" & _
"UID=;SourceType=DBC;Exc
lusive=No;" & _
"BackgroundFetch=Yes;Col
late=Machine;" & _
"SourceDB=c:\logbook\log
book.dbc"
SQLString = "Select * from Mission"
' create connection and recordset objects
Set Conn = CreateObject("ADODB.Connection")
Conn.Open (ConnectString)
Set rs = Conn.Execute(SQLString)
' open recordset object
rs.Close
rs.CursorType = adOpenStatic
rs.CursorLocation = adUseClient
rs.LockType = adLockOptimistic
rs.Open
' display information about what features the
' recordset object supports
Form1.Print "CURSOR TYPE: "; rs.CursorType
Form1.Print
Form1.Print " ADDNEW: "; rs.Supports(adAddNew)
Form1.Print "APPROX POSITION: "; rs.Supports(adApproxPosition)
Form1.Print " DELETE: "; rs.Supports(adDelete)
Form1.Print " MOVE PREVIOUS: "; rs.Supports(adMovePrevious)
Form1.Print " UPDATE: "; rs.Supports(adUpdate)
Form1.Print
rs.MoveLast
rs.Close
Conn.Close
End Sub
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer