Answered by:
ADO and Recordset Errors (every other procedure call)

Question
-
I am trying to anticapate errors so I can workaround potiential problems. However the following routine only produces an error every other time.
anybody know how or why?First Execute: Errors
Second Execute: No Errors
Third Execute: Errors
Fourth Execute: No Errors
.
.
.
and so on.This is what I am wanting a solution for:
I have two users, both using a identical recordset.
The first user to save the data back to the database wins. .UpdateBatch
Any other user has to resync the recordset or an error is to occur.Of course, this only applies to the users that have obtained a recordset since the last update.
Any pointers?
_____________________________________________________________________________________________________________________________________________________
Public Sub Test()
' THE CODE
On Error GoTo Err_Handler
Dim RST1 as New ADODB.Recordset
Dim RST2 as New ADODB.Recordset
' Both RST1 & RST2 excutes the same commandSet RST1 = ... ' LOCKTYPE ---> adLockBatchOptimistic
Set RST2 = ... ' CursorType ---> adUseClient
' CursorLocation ---> adOpenStatic
' CommandType ---> adCmdStoredProc
' ActiveConnection ---> CurrentProject.Connection' RST1 & RST2 Recordcount > 10
RST1.MoveFirst
RST2.MoveFirst
RST2.MoveNext
RST1("<Field1>").Value = "<Value1>"
RST2("<Field1>").Value = "<value2>"
RST2.MoveFirst
RST1.UpdateBatchRST2("<Field1>").Value = "<Value3>"
' The next line is where the error occurs.
RST2.UpdateBatchFinish:
RST1.Close
RST2.Close
Set RST1 = Nothing
Set Rst2 = Nothing
Exit SubErr_Handler:
MsgBox Err.Number & " ---> " & Err.Source & VbCrLf & Err.Description,vbOKOnly,"Error!"
Debug.Print RST1.Status ' Returns 8
Debug.Print RST2.Status ' Returns 2050
Resume FinishEnd Sub
_____________________________________________________________________________________________________________________________________________________
_____________________________________________________________________________________________________________________________________________________ERR OBJECT RETURNS:
_____________________________________________________________________________________________________________________________________________________
Err.Number ---> -2147217887
Err.Number-VbObjectError ---> 3617
Err.Source ---> Provider
Err.Description ---> "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done."
Err.HelpContext ---> 1240640
Err.HelpFile ---> "C:\PROGRA~1\COMMON~1\MICROS~1\VBA\VBA6\1033\VbLR6.chm"
Err.LastDllError ---> 0
__________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
ADODB.Recordset.ActiveConnection.Errors & ADODB.Recordset.ActiveCommand.ActiveConnection.Errors
_____________________________________________________________________________________________________________________________________________________
ITEM 1: (1).
Description ---> "One or more properties cannot be returned."
HelpContext ---> 0
HelpFile ---> ""
NativeError ---> 44
Number ---> -2147217887
Source ---> "MSDataShape"
SQLState ---> ""Item 2: (2).
Description ---> "Provider does not support the property."
HelpContext ---> 1240640
HelpFile ---> ""
NativeError ---> -2147217887
Number ---> -2147217887
Source ---> "ADODB.Connection"
SQLState ---> ""_____________________________________________________________________________________________________________________________________________________
Answers
-
Here's an ADO forum: http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataset/threads
Not sure if you need a dataset forum though.
Thanks!
Ed Price (a.k.a User Ed), SQL Server Experience Program Manager (Blog, Twitter, Wiki)
- Marked as answer by Ed Price - MSFTMicrosoft employee, Owner Monday, July 23, 2012 11:18 PM
All replies
-
Hello,
As this question is more related to ADO technology I suggest you ask this ask this question is a ADO technology related forum or newsgroup.Sorry for any inconvenience.
Thanks
We have published a VSTO FAQ recently, you can view them from the entry thread VSTO FAQ.
If you have any feedbacks or suggestions on this FAQ, please feel free to write us emails to colbertz@microsoft.com.
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us. -
Here's an ADO forum: http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataset/threads
Not sure if you need a dataset forum though.
Thanks!
Ed Price (a.k.a User Ed), SQL Server Experience Program Manager (Blog, Twitter, Wiki)
- Marked as answer by Ed Price - MSFTMicrosoft employee, Owner Monday, July 23, 2012 11:18 PM