views:

261

answers:

2

We commonly use MS Visual Foxpro v9.0 SP1, the language, tables, and reports. However, sometimes we use an ODBC driver to connect to the tables. The ODBC driver was written for Foxpro v6, and doesn't support certain nested selects, autoincrement fields, or embedded casts.

We would like to find an alternative to what we have. It could be another ODBC driver that works with Visaul Foxpro v9, or a complete alternative to ODBC. Is there such a thing?

Thanks.

+1  A: 

You can via COM+ and do almost anything in VFP, however, you have security issues through Admin Tools, Component Services..

You can either build as a single-threaded or multi-threaded DLL.

Once registered, and the typelibrary info is "Add Referenced" to a C# (or other) app, you can make function calls with whatever parameters you need. There are many things you can return back, but typically tables, I send back as XML (via Foxpro's XMLAdapter class), then stream convert to a table once in C#. Its been a while since I worked it that way, but that give tremendous flexibility as you can do your queries, scan loops, and other complex conditional testing and updating of the cursor before generating out the XML and returning it as a string.

DEFINE CLASS YourClass as CUSTOM  OLEPUBLIC
  FUNCTION GetMyData( lcSomeString as String)
    select * from (YourPath + "SomeTable" ) where ... into cursor C_SomeCursor readwrite
    .. any other manipulation, testing, etc...
    oXML = CREATEOBJECT( "xmladapter" )
    lcXML =  ""
    oXML.AddTableSchema( "C_SomeCursor" )
    oXML.ToXML( "lcXML", "", .f. )

    return lcXML
  ENDFUNC 
ENDDEFINE
DRapp
You answered exactly what I asked, and thanks for that by the way :). What I meant to ask was, "What type of ODBC drivers, alternatives to the MS Foxpro 6.0, are out there that we could use?" Actually I'm glad you posted your answer because I've been really wondering how to utilize a mid-tier architecture via Foxpro and this shows how to get it going. Thanks again.
jetimms
By the way, what are the security issues that you mentioned?
jetimms
There's actually an OleDB driver for VFP9 available, but I don't know your versions of the data. As for security, if you run as a .DLL, it would have whatever rights via the .Net user account, and if its to a directory that's restricted, it won't work, however, you can do impersinations. I'm not a security specialist, but hope to have guided you in A direction to move forward. I've acutally written some wrapper-class in C#.net that allows direct communicating to VFP tables for SQL-Select, Update, Delete, and accommodates for parameterized queries to help restrict SQL-Injection.
DRapp
if you want to contact me direct... [email protected]
DRapp
+2  A: 

(Talk about reuse, just answered this in another thread today)

If you are looking for an ODBC driver for VFP databases and tables you might consider looking at Advantage Database from iAnywhere. The have a local engine and a server engine. The local engine has the engine to access DBF data, but for your case, it also has an ODBC drive that works with VFP data up to and including the current Visual FoxPro 9. The local engine and the included ODBC driver are free.

http://www.sybase.com/ianywhere

Rick Schummer
I've gotta try that one out now. Thanks for the info and sorry for the deja vu :]
jetimms