Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Inserting a new record via OleDbCommand
Message
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Divers
Thread ID:
00693070
Message ID:
00693077
Vues:
24
Does the same Insert-SQL works from VFP?

>I'm trying to add a new record to a VFP table. This table is part of a VFP database and has a primary key that is automatically generated via a default value. From .NET, I build the INSERT command and try to add the new record. It keeps failing with a trigger failure. I tried inserting a record into a table that didn't have a PK/default value and it worked just fine. It looks like the automatic ID stuff isn't firing or I need to prefetch the value somehow.
>
>My code:
>
>
>string insertString = "INSERT INTO test (cField, cSecond) VALUES ('one', 'two')"
>
>System.Data.OleDb.OldDbCommand oleCmd = new System.Data.OleDb.OleDbCommand();
>oleCmd.Connection = DataHandler.dataConnection;
>
>oleCmd.CommandTest = insertString.ToString();
>
>try
>{
>   oldCmd.ExecuteNonQuery();
>}
>catch (System.Data.OldDb.OleDbException e)
>{
>   System.Diagnostics.Debug.Assert(false, "Exception Caught", e.Message );
>}
>
>
>
>There is also a field in the test table named "iid" that is my PK. Again, the code works if I don't have an automatically generated PK. Any ideas on how I'm supposed to handle this?
- Jayesh
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform