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

Click here to load this message in the networking platform