Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to call a SP from C# database VFP
Message
 
 
To
24/09/2007 16:16:35
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01256470
Message ID:
01256488
Views:
23
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform