jbailey268
Programmer
This code is suppose to eventually be called from a .NET web app. This seemed like the best forum.
I first tried posting this to the ASP .NET tek-tips and made only small syntactical progress. It didn’t solve my overall problem.
I first must explain that my stored procedure in the Foxpro DBC has nothing to do with the data tables contained therein. There is no INSERT, SELECT or UPDATE.
This stored procedure makes an Alpha-Sort of a string. “STRING” becomes “GINRST” and “MAIN STREET” becomes “ AEEIMNRSTT”
Here is the code for the OleDb call:
strConnectionString = _
"Provider=vfpoledb.1;Data Source=c:\develop\databases\sa_tables.dbc;Collating Sequence = machine"
con = New OleDbConnection(strConnectionString)
con.Open()
cmd = New OleDbCommand("scrabblesort", con)
cmd.CommandType = CommandType.StoredProcedure
(The first (and only) parameter is called tStrgVal in the VFP Stored procedure, thus the following.)
cmd.Parameters.Add(New OleDbParameter(“@tStrgVal”, OleDbType.Char, 12))
cmd.Parameters("@tStrgVal").Value = “Report1”
cmd.Parameters("@tStrgVal").Direction = ParameterDirection.Input
cmd.Parameters.Add("@retval", OleDbType.Char, 12)
cmd.Parameters("@retval").Direction = ParameterDirection.Output
Dim objDataReader As OleDbDataReader
‘Execute the Stored Procedure
(Everything executes well up to here)
objDataReader = cmd.ExecuteReader()
(This line triggers an error)
OleDbException was Unhandled
A try catch didn’t help.
The error was Variable 'Q0P1' is not found
As a side bar objDataReader = cmd.ExecuteScaler() returned the error message Variable 'Q1P1' is not found. Have no clue where Q0P1 is from.
I subsequently modified my VFP stored procedure to just simple return “Hello World” yet that didn’t fire either. So it’s nothing in the code. I suspect I'm just not getting in.
I am using VFP 8.0 and the .NET Visual Studio 2005
All the help I’ve seen on web sites have code similar to the above, but they all seem to read as if data with rows are returned. A data reader that reads row(0), then row(1) etc. as if I did some kind of Select statement. Like I said up front, it’s simply a VFP function that is returning a value. I would have thought this is something common to do.
Incidentally, from within the VFP Command window:
open DATABASE C:\Develop\Databases\SA_Tables.dbc
? scrabblesort('MIKE')
This shows EIKM (as expected). Works fine here in VFP.
Am I thinking too inside or too outside the box?
Thanks for your assistance. Very Much appreciate any help or suggestion.
I first tried posting this to the ASP .NET tek-tips and made only small syntactical progress. It didn’t solve my overall problem.
I first must explain that my stored procedure in the Foxpro DBC has nothing to do with the data tables contained therein. There is no INSERT, SELECT or UPDATE.
This stored procedure makes an Alpha-Sort of a string. “STRING” becomes “GINRST” and “MAIN STREET” becomes “ AEEIMNRSTT”
Here is the code for the OleDb call:
strConnectionString = _
"Provider=vfpoledb.1;Data Source=c:\develop\databases\sa_tables.dbc;Collating Sequence = machine"
con = New OleDbConnection(strConnectionString)
con.Open()
cmd = New OleDbCommand("scrabblesort", con)
cmd.CommandType = CommandType.StoredProcedure
(The first (and only) parameter is called tStrgVal in the VFP Stored procedure, thus the following.)
cmd.Parameters.Add(New OleDbParameter(“@tStrgVal”, OleDbType.Char, 12))
cmd.Parameters("@tStrgVal").Value = “Report1”
cmd.Parameters("@tStrgVal").Direction = ParameterDirection.Input
cmd.Parameters.Add("@retval", OleDbType.Char, 12)
cmd.Parameters("@retval").Direction = ParameterDirection.Output
Dim objDataReader As OleDbDataReader
‘Execute the Stored Procedure
(Everything executes well up to here)
objDataReader = cmd.ExecuteReader()
(This line triggers an error)
OleDbException was Unhandled
A try catch didn’t help.
The error was Variable 'Q0P1' is not found
As a side bar objDataReader = cmd.ExecuteScaler() returned the error message Variable 'Q1P1' is not found. Have no clue where Q0P1 is from.
I subsequently modified my VFP stored procedure to just simple return “Hello World” yet that didn’t fire either. So it’s nothing in the code. I suspect I'm just not getting in.
I am using VFP 8.0 and the .NET Visual Studio 2005
All the help I’ve seen on web sites have code similar to the above, but they all seem to read as if data with rows are returned. A data reader that reads row(0), then row(1) etc. as if I did some kind of Select statement. Like I said up front, it’s simply a VFP function that is returning a value. I would have thought this is something common to do.
Incidentally, from within the VFP Command window:
open DATABASE C:\Develop\Databases\SA_Tables.dbc
? scrabblesort('MIKE')
This shows EIKM (as expected). Works fine here in VFP.
Am I thinking too inside or too outside the box?
Thanks for your assistance. Very Much appreciate any help or suggestion.