Tonatiuh
Aug 4th, 1999, 07:25 PM
I found a source code in MSDN (Article ID Q172592 'HOWTO: Open a Visual FoxPro Table for Read/Write') where was a source code about to open and work with a FoxPro database from Visual Basic using RDO object.
When I use VB6 I don't get any error message but Update after an Edit don't work (Update after an AddNew works well).
When I use VB5 I get an error message when Update after an Edit.
Run-time error '40002':
37000: [Microsoft][ODBC Visual FoxPro Driver]Syntax error.
(Update after an AddNew works well)
Option Explicit
Dim cn As New rdoConnection
Dim rs As rdoResultset
Dim SQL As String
Private Sub Command1_Click()
rs.edit
End Sub
Private Sub Command2_Click()
rs(1) = Text2.Text
rs.Update
End Sub
Private Sub Command3_Click()
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
Unload Me
End Sub
Private Sub Command4_Click()
rs.MoveNext
If Not (rs.EOF) Then
Text1.Text = rs(0)
Text2.Text = rs(1)
Else
rs.MoveLast
End If
End Sub
Private Sub Command5_Click()
rs.MovePrevious
If Not (rs.BOF) Then
Text1.Text = rs(0)
Text2.Text = rs(1)
Else
rs.MoveFirst
End If
End Sub
Private Sub Form_Load()
' Using a DSN-less connection to open a free table
cn.Connect = "SourceType=DBF;" _
& "SourceDB=C:\Vfp\Samples\Data;" _
& "Driver={Microsoft Visual FoxPro Driver}"
cn.CursorDriver = rdUseOdbc
cn.EstablishConnection "rdDriverNoPrompt"
SQL = "select * from customer"
Set rs = cn.OpenResultset(SQL, rdOpenKeyset, rdConcurRowVer)
rs.MoveFirst
Text1.Text = rs(0)
Text2.Text = rs(1)
End Sub
Of course I select the RDO object from References option in Proyect menu. Boht VB5 and 6 are enterprise editions.
Can someone helps me? Any idea will be deeply appreciated.
Thaks!
Ulises
When I use VB6 I don't get any error message but Update after an Edit don't work (Update after an AddNew works well).
When I use VB5 I get an error message when Update after an Edit.
Run-time error '40002':
37000: [Microsoft][ODBC Visual FoxPro Driver]Syntax error.
(Update after an AddNew works well)
Option Explicit
Dim cn As New rdoConnection
Dim rs As rdoResultset
Dim SQL As String
Private Sub Command1_Click()
rs.edit
End Sub
Private Sub Command2_Click()
rs(1) = Text2.Text
rs.Update
End Sub
Private Sub Command3_Click()
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
Unload Me
End Sub
Private Sub Command4_Click()
rs.MoveNext
If Not (rs.EOF) Then
Text1.Text = rs(0)
Text2.Text = rs(1)
Else
rs.MoveLast
End If
End Sub
Private Sub Command5_Click()
rs.MovePrevious
If Not (rs.BOF) Then
Text1.Text = rs(0)
Text2.Text = rs(1)
Else
rs.MoveFirst
End If
End Sub
Private Sub Form_Load()
' Using a DSN-less connection to open a free table
cn.Connect = "SourceType=DBF;" _
& "SourceDB=C:\Vfp\Samples\Data;" _
& "Driver={Microsoft Visual FoxPro Driver}"
cn.CursorDriver = rdUseOdbc
cn.EstablishConnection "rdDriverNoPrompt"
SQL = "select * from customer"
Set rs = cn.OpenResultset(SQL, rdOpenKeyset, rdConcurRowVer)
rs.MoveFirst
Text1.Text = rs(0)
Text2.Text = rs(1)
End Sub
Of course I select the RDO object from References option in Proyect menu. Boht VB5 and 6 are enterprise editions.
Can someone helps me? Any idea will be deeply appreciated.
Thaks!
Ulises