Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Are Stored Procedures Supported?
Message
General information
Forum:
ASP.NET
Category:
Visual FoxPro Toolkit for .NET
Miscellaneous
Thread ID:
00663789
Message ID:
00663836
Views:
15
Hi Frank,

> I need to be able to execute a Store Procedure. If I copy the SP and execute the code via SQLEXECUTE it runs without errors. If I just call the SP, I get an error.

Sorry, I must have missed your previous request on this issue. Here is an example that demonstrates how to call a stored procedure using the VFP Toolkit for .NET
Dim lcConnectionString As String
Dim oConn As OleDbConnection
Dim oCommand As New OleDbCommand()

'Specify the connection string
lcConnectionString = "Provider=SQLOleDb; server=(local); database=VFPToolkitNET; UID=sa; Pwd="

'Specify the stored procedure. (In my case GetVFPCommand)
oCommand.CommandText = "GetVFPCommand"
oCommand.CommandType = CommandType.StoredProcedure

'Create a new parameter and add it to the parameters collection
Dim oParam1 As New OleDbParameter("@t_Command", OleDb.OleDbType.VarChar)
oParam1.Value = "ALEN"
oCommand.Parameters.Add(oParam1)

'Connect to the Database, execute the query and disconnect
'SqlConnect(), SqlExecute(), SqlDisconnect()
oConn = SqlConnect(lcConnectionString)

'Extra step required in this release of toolkit. This will be fixed in a future release
oCommand.Connection = oConn

'Execute and disconnect
goView = SqlExecute(oConn, oCommand, "CustomerList")
SqlDisConnect(oConn)

'Select the default cursor
VFPToolkit.vfpData.Select(goView)
Browse()
There is a bug in the toolkit that requires an extra step to call stored procedures. It has been fixed for the next release.
'Requires specifying the connection explicitely when calling stored procedures
oCommand.Connection = oConn
Hope this helps,
Kamal
Previous
Reply
Map
View

Click here to load this message in the networking platform