Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to edit a record using ADODC
Message
From
24/01/2001 09:58:25
 
 
To
23/01/2001 23:24:45
General information
Forum:
Visual Basic
Category:
Database DAO/RDO/ODBC/ADO
Miscellaneous
Thread ID:
00467718
Message ID:
00467859
Views:
28
>Yes, There is no Edit method for ADO, but you can use Select statement and then trap the error code, the codes should be as follow:
>
>On Error goto ErrorHandler
>Dim mSQL as String
>Dim rsMyRecord as ADODB.Recordset
>
>mSQL = "Select * from MyTable Where MyCode = 'myCriteria' Order by MyCode"
>rsMyRecord.Open mSQL,YourConnectionString ..., adOpenKeyset, adLockOptimistic
>rsMyRecord.MoveLast
>
>rsMyRecord!MyField1 = ...
>rsMyRecord!MyField2 = ...
>rsMyRecord.Update
>rsMyRecord.Close
>
>ErrorHandler:
>Select Case Err.Number
>case 0
>Case 3021 ' Specified Record not found
>' You May Add New Record Here
>Resume next
>Case else ' Trap another errors
>...
>...
>End select
>
>Best Regards
>Winan

You can check the Recordcount property to see if the SQL statement returned any rows.
With this option (your code above) you could be duplicating code (in the main body as well as on your error handler) or putting all of the code in the error handler.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform