Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Accessing a VFP Stored Procedure with OleDb From .NET

Accessing a VFP Stored Procedure with OleDb From .NET

Accessing a VFP Stored Procedure with OleDb From .NET

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)
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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close