Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Adding/Editing a record in a new recordset
Message
 
À
17/09/1999 14:27:56
Information générale
Forum:
Visual Basic
Catégorie:
Bases de données DAO/RDO/ODBC/ADO
Divers
Thread ID:
00266094
Message ID:
00266290
Vues:
22
>I have a form which displays an ADO recordset from a table. The user can either select a record and edit it, or add a new record- pretty basic. However, in the add/edit form, I want to use a new recordset to add or edit the record because I'm using an MDI interface in which a user could view/add/edit multiple records at once. I want the new recordset to contain only the one record that is being added/edited. Editing is not a problem, but how can I create a recordset in which the only record is the one that I want to add?
>
>I figured this would be better for performance than creating a new recordset that contains all of the records when all I want to do is add or edit one new record. Am I wrong?

To create a recordset with the one record you want to add, simply create a recordset with an impossible condition "SELECT * FROM TableA WHERE Field = 'ImpossibleCondition'". After this, use the AddNew Method on this recordset. This way your recordset will only contain the one record you just added.

BTW, if you use this technique, you are surely in bound mode. If not, why do you create a recordset? You could simply use an INSERT SQL statement to append to your database (with the EXECUTE method of the Connection object). This is the way you will get most performance.
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform