Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to edit a record using ADODC
Message
De
23/01/2001 23:24:45
 
 
À
23/01/2001 21:47:36
Information générale
Forum:
Visual Basic
Catégorie:
Bases de données DAO/RDO/ODBC/ADO
Divers
Thread ID:
00467718
Message ID:
00467752
Vues:
22
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform