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:
00693847
Vues:
40
>>
>>You will need to set CommandType for the command object.
>>
>>For example,
>>
>>oleCmd.CommandType = CommandType.StoredProcedure
>
>When I originally tried that (and I just tried it again), it (the ExecuteNonQuery() ) fails with a "Unrecognized command verb." If I don't include it, it seems to work (except for the return value). I've checked the ID table and the table PK is definitely being incremented.

Try the following code..
OleConnection nConn = new OleConnection("Your Connection String");

OleCommand OleCMD = new OleCommand("NewId", nConn);
OleCMD.CommandType = CommandType.StoredProcedure;

SqlParameter myParm = OleCMD.Parameters.Add("@TableId", SqlDbType.NVarChar, 15);
myParm.Value = "User";

nConn.Open();

object oReturnValue = OleCMD.ExecuteScalar();

Console.WriteLine(oReturnValue.ToString())
- Jayesh
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform