Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to access DBC stored procs in .Net
Message
 
 
À
21/12/2004 14:47:24
Information générale
Forum:
Visual FoxPro
Catégorie:
Visual FoxPro et .NET
Divers
Thread ID:
00971118
Message ID:
00971126
Vues:
24
This message has been marked as the solution to the initial question of the thread.
>Hi all,
>
>How do I access my VFP database stored procedures from .Net? C# preferred.
>
>Thanks.


Here is a sample code that I use to call VFP Stored Procedure:
string connectionString = "PROVIDER=VFPOLEDB.1;" + "DATA SOURCE=" + strDataLocation + ";UID='';PWD=''";
string commandText = "My_StoredProc";

OleDbCommand oCommand = new OleDbCommand();
OleDbConnection OleDbConn2Vfp = new OleDbConnection(connectionString);
OleDbConn2Vfp.Open();
oCommand.Connection = OleDbConn2Vfp;
oCommand.CommandText = commandText;
oCommand.CommandType = CommandType.StoredProcedure;

// Pass parameters to SP
oCommand.Parameters.Add( "@Param1Name", strParam1Value );
oCommand.Parameters.Add( "@Param2Name", strParam2Value );
oCommand.Parameters.Add( "@Param3Name", strParam3Value );

try 
{
strReturnXml = (string) oCommand.ExecuteScalar();
}
catch 
{
strErrorMessage = "Failed to execute Stored Procedure";
}
finally 
{
OleDbConn2Vfp.Close();
}
Please let me know if you have any questions about my code.

HTH
"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