Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to call a SP from C# database VFP
Message
 
 
À
24/09/2007 16:16:35
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01256470
Message ID:
01256488
Vues:
21
This message has been marked as the solution to the initial question of the thread.
>Hi, all, i created a Store Procedure (SP) on VFP 9, database. How can i call this SP from C# ??
>T.I.A.

Here is a simple example:
string connectionString = "PROVIDER=VFPOLEDB.1;" + "DATA SOURCE=" + 
strDataLocation + ";UID='';PWD=''";

// name of your Stored Procedure in VFP
string commandText = "SP_MYPROC";

OleDbCommand oCommand = new OleDbCommand();
OleDbConnection OleDbConn2Vfp = new OleDbConnection
(connectionString);

OleDbConn2Vfp.Open();
oCommand.Connection = OleDbConn2Vfp;
oCommand.CommandText = commandText;
oCommand.CommandType = CommandType.StoredProcedure;
oCommand.Parameters.AddWithValue( "@ParamName", cParamValue );

try 
{
  strReturnXml = (string) oCommand.ExecuteScalar();
}
  catch (Exception e)
{
  strErrorMessage = "Failed to execute Stored Procedure: " +   e.Message;
}
finally 
{
   OleDbConn2Vfp.Close();
}
I hope this helps.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform