Smart questions
Smart answers
Smart people
Join Tek-Tips Forums
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • 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!

Join Tek-Tips
*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.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Accessing a VFP Stored Procedure with OleDb From .NET

jbailey268 (Programmer) (OP)
2 Oct 07 16:27
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.

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!

Back To Forum

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