M
MyndPhlyp
(also posted over at ms.pub.access.externaldata)
I'm using Access 2000 and going after the linked tables with ADO. The FoxPro
tables are accessed through ODBC (Microsoft Visual FoxPro Driver
v6.01.8630.01) using database type "Visual FoxPro database (.DBC)" with the
Null and Deleted driver options unchecked. If I can trust the comments in
the Database Properties in Visual FoxPro, the database is vintage 3.50 SP1.
I can .AddNew/.Update to my heart's content, but I can't seem to
..Delete/.Update records. It doesn't matter if I check or uncheck the
"Exclusive", "Deleted" or "Fetch data in background" options in the ODBC DSN
configuration.
A typical scenario would be:
Dim conLocal as New ADODB.Connection
Dim rs As New ADODB.Recordset
Set conLocal = CurrentProject.Connection
rs.CursorLocation = adUseClient
rs.Open "mytable", conLocal, adOpenDynamic, adLockPessimistic,
adCmdTableDirect
rs.Filter = "mystring = '12345'"
Do Until rs.EOF
rs.Delete
rs.Update
rs.MoveNext
Loop
Pretty straightforward stuff, but if I go back and look at the table through
either Access or FoxPro, the records are still there. (And, in FoxPro, none
of the records are flagged as deleted.)
It gets better ...
Successive runs of the same code fall apart on the .Delete because the
record is flagged for deletion (even though the ODBC driver has been
configured to not deliver deleted records and the adLockPessimistic
supposedly puts me into "immediate mode"). So I end up wrapping the .Delete
and .Update with:
If rs.Status Then
rs.Delete
rs.Update
End If
rs.MoveNext
And just to make matters worse, I cannot seem to trap the actual value of
..Status into a variable or use in in a comparison. For example:
If rs.Status = ADODB.adRecOK Then '.. always test true
varMyStatus = rs.Status '.. always results in varMyStatus = 0
But by using breakpoints or waiting for the code to fall apart and entering
Debug, I know the status of the supposedly deleted records is 262144
(ADODB.adRecDBDeleted) by running the mouse cursor over the rs.Status
command.
What's the trick to really deleting records in a linked FoxPro table using
ADO in Access 2000? And for bonus trivia points and a chance to go on to our
expert round, when the records /*are*/ finally deleted, do I still have to
go back to FoxPro somewhere along the line and do a PACK on the table(s)?
I'm using Access 2000 and going after the linked tables with ADO. The FoxPro
tables are accessed through ODBC (Microsoft Visual FoxPro Driver
v6.01.8630.01) using database type "Visual FoxPro database (.DBC)" with the
Null and Deleted driver options unchecked. If I can trust the comments in
the Database Properties in Visual FoxPro, the database is vintage 3.50 SP1.
I can .AddNew/.Update to my heart's content, but I can't seem to
..Delete/.Update records. It doesn't matter if I check or uncheck the
"Exclusive", "Deleted" or "Fetch data in background" options in the ODBC DSN
configuration.
A typical scenario would be:
Dim conLocal as New ADODB.Connection
Dim rs As New ADODB.Recordset
Set conLocal = CurrentProject.Connection
rs.CursorLocation = adUseClient
rs.Open "mytable", conLocal, adOpenDynamic, adLockPessimistic,
adCmdTableDirect
rs.Filter = "mystring = '12345'"
Do Until rs.EOF
rs.Delete
rs.Update
rs.MoveNext
Loop
Pretty straightforward stuff, but if I go back and look at the table through
either Access or FoxPro, the records are still there. (And, in FoxPro, none
of the records are flagged as deleted.)
It gets better ...
Successive runs of the same code fall apart on the .Delete because the
record is flagged for deletion (even though the ODBC driver has been
configured to not deliver deleted records and the adLockPessimistic
supposedly puts me into "immediate mode"). So I end up wrapping the .Delete
and .Update with:
If rs.Status Then
rs.Delete
rs.Update
End If
rs.MoveNext
And just to make matters worse, I cannot seem to trap the actual value of
..Status into a variable or use in in a comparison. For example:
If rs.Status = ADODB.adRecOK Then '.. always test true
varMyStatus = rs.Status '.. always results in varMyStatus = 0
But by using breakpoints or waiting for the code to fall apart and entering
Debug, I know the status of the supposedly deleted records is 262144
(ADODB.adRecDBDeleted) by running the mouse cursor over the rs.Status
command.
What's the trick to really deleting records in a linked FoxPro table using
ADO in Access 2000? And for bonus trivia points and a chance to go on to our
expert round, when the records /*are*/ finally deleted, do I still have to
go back to FoxPro somewhere along the line and do a PACK on the table(s)?