Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to edit a record using ADODC
Message
From
23/01/2001 23:24:45
 
 
To
23/01/2001 21:47:36
General information
Forum:
Visual Basic
Category:
Database DAO/RDO/ODBC/ADO
Miscellaneous
Thread ID:
00467718
Message ID:
00467752
Views:
21
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform