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:
00694012
Vues:
22
>>
>>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())
>>
>>
>
>That also doesn't work. Actually, the code you provided assumes I'm connecting to a SQL server database. I'm using OLE-DB to connect to a Visual FoxPro database. I adjusted the code to reference the OleDb class instead, but it fails with a "Input string was not in a correct format." error when ExecuteScaler() fires.

Oh, I see. I forgot to change SQL ref in all statements. Did you try
OleParameter myParm = OleCMD.Parameters.Add("@TableId", OleDbType.VarChar, 15);
- Jayesh
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform