Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Strange error with rs.Update
Message
 
To
All
General information
Forum:
Visual Basic
Category:
Database DAO/RDO/ODBC/ADO
Title:
Strange error with rs.Update
Miscellaneous
Thread ID:
00649508
Message ID:
00649508
Views:
71
Hi - I am using VB as my front end with VFP as my database with tables...
this is how I set up my connection...
Option Explicit
Public DB As ADODB.Connection
Public Function getConn()
Set DB = New ADODB.Connection
DB.Open "Driver={Microsoft Visual FoxPro
Driver};SourceType=DBC;SourceDB=d:\vb6projects\youthbase\data\youthbase.dbc;
Exclusive = No;"
End Function
and to get a recordset...
Dim rs as ADODB.Recordset
Set rs = New ADODB.Recordset
rs.Open "select * from users where us_userid = '" & strUser & "'", DB,
adOpenStatic, adLockOptimistic, adCmdText
This is all fine... but I am programming for shared access...

So user A and user B both open this recordset through a form - user A MAKES
NO CHANGES to the recordset and then closes it but the form stays open...
user B makes changes and then saves them and closes his form...

User A now reopens the recordset and attempts to make changes - when
rs.Update is called errors occur...

This is the ado error collection debug.print etc

-2147467259 Query-based update failed because the row to update could not be
found.
-2147217887 Multiple-step OLE DB operation generated errors. Check each OLE
DB status value, if available. No work was done.

So I understand although it doesn't quite add up that if changes have been
made whilst another user has that record open you get this error and you can
trap it and ask the user whether he wants to refresh the data or just save
his changes etc - basis multi user handling...

So I trap the -2147467259 error and use this code...
errHandler:
If Err.Number = -2147467259 Then
Err.Clear
rs.CancelUpdate
rs.Close
Set rs = Nothing
Set rs = New ADODB.Recordset
rs.Open "select * from users where us_userid = '" & strUser & "'", DB,
adOpenStatic, adLockOptimistic, adCmdText
Resume retryUpdate
End If
this returns the program back to where the error occurred...
retryUpdate:
rs!us_loggedin = True
rs!us_atpc = oAppPCName
If rs!us_firsttime = True Then
oAppFirstTime = True
rs!us_firsttime = False
Else
oAppFirstTime = False
End If
On Error GoTo errHandler
rs.Update
BUT the same error occurs and we are back into the error handling routine...

Please help if you have any ideas...

Chris
Chris Maiden
Email
Web
Next
Reply
Map
View

Click here to load this message in the networking platform