Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Strange error with rs.Update
Message
General information
Forum:
Visual Basic
Category:
Database DAO/RDO/ODBC/ADO
Miscellaneous
Thread ID:
00649508
Message ID:
00650311
Views:
59
Do you have a Primary Key in your table?

>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
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform