Accessing VFP9.0 Stored procedures with .NET

I've been fighting an almost epic battle these last few days with Foxpro, to try to access its Stored Procedures with ADO.NET.
Here is my code:

Dim conn As String = "Data Source=Q:\network\Gestion\stage.dbc;Provider='VFPOLEDB.1';password='';user id=''"

Dim OleDbConnection2 As OleDbConnection = New OleDbConnection(conn)

Dim cmmSelect As OleDbCommand = New OleDbCommand("ProcGrillePosteA", OleDbConnection2)

cmmSelect.CommandType = CommandType.StoredProcedure

'Dim adaSelect As OleDbDataAdapter = New OleDbDataAdapter(cmmSelect)

cmmSelect.Parameters.Add("VGemployeur", "4397")

cmmSelect.Parameters.Add("VGsessioncourante", "20052")

cmmSelect.Parameters.Add("VGaffichage", "COTE")

'on se connecte a la BD et on effectue la requete

Try

OleDbConnection2.Open()

Dim dt As OleDbDataReader = cmmSelect.ExecuteReader()

'Gestion des exceptions

Catch ex As Exception

Dim str As String = ex.Message

Finally

OleDbConnection2.Close()

End Try

I've tried various approaches, including a declaration  like :
Dim sSelect As String = "ProcGrillePosteA('4397','20052','COTE')"
for the command string...

yet nothing works. I can connect and send a regular SQL select query to the  Foxpro database, but I just can't manage it with a stored procedure

I always get this message:
 "Connectivity error: [Microsoft][Gestionnaire de pilotes ODBC] Connexion non ouverte" which is basically saying the connection isnt opened. Yet, If i comment out the reader, the connection opens and closes without any problems.

The stored procedure i'm trying to run should return a set of rows.
Any help would be appreciated.




Answer this question

Accessing VFP9.0 Stored procedures with .NET

  • Hatem Rabie

    Hi Frederyk,

    Do you have the latest VFP OLE DB provider, downloadable from the Fox web pages

    Which version of Visual FoxPro was your database created with

    What is the code for your VFP stored procedure Are you sure it is returning an ADO recordset and not just selecting data into a Fox cursor


  • Pedro Pinto

    Does no one have any insights into this

  • T. McClung

    it should be noted i tried variations on the present code to no avail, Like removing the commadtype instruction, using a dataadapter with a fill, etc...

  • Accessing VFP9.0 Stored procedures with .NET