Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

connect to foxpro from .net

Status
Not open for further replies.

dinger2121

Programmer
Sep 11, 2007
439
US
Hello,
I am having a horrible time trying to connect to foxpro from .net. I have tried multiple iterations of connection strings and have ended up with various error codes.

Here is the latest -
Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;SourceDB=c:\;Exclusive=No; Collate=Machine;NULL=NO;DELETED=NO;BACKGROUNDFETCH=NO;

This is returning Driver does not support this function
my query is simple - select * from table

I had initially thought that it may have been a permissions issue - I was trying to access a remote table. So I then copied it to my c:\ drive hoping that would work, but that is where I am getting the errors.

I am somewhat new to FoxPro, so I just copied the .dbf and .cdx files to my local drive to use as freestanding tables - is that correct usage, or could that be causing a problem?

Thanks for any thoughts
 
What version of the ODBC driver are you using? And what version of VFP did you use to create your database?

The VFP ODBC driver hasn't been updated since VFP 6.0. If the database was created in a later version, or if the structure was amended to use features introduced in a later version, then you might well get "driver does not support this function".

You might need to use an up-to-date OLE DB driver, or create a version of the database under VFP 6.0 or earlier.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
I am trying to report against a 3rd party application. How can I tell which version the tables were created in?
 
It's not onyl the tables, also the dbc can have eg events. DBFs type is encoded in the first byte of the file. See here:
If you don't know how to read the first byte of a file, a hexeditor will help you do that.

But it'll be prompted by the ODBC driver, if he can't access a DBF. In fact you could have induced a problem, if that dbf and cdx files are a table belonging to a database.

I'd rather recommend, you better use oledb from .net anyway. Craig Berntson also suggested this in the ms.public.fox.dbc newsgroup for example.

Check out for working sample connectionstrings.

Amongst others they recommend System.Data.Odbc.OdbcConnection for ODBC connections and give a connection string for that.

Bye, Olaf.
 
Just copying the DBF and CDX files may not be enough. If the application uses a Database Container, you will not be able to open the DBF files. You may also need the .db* files too.

Also, the ODBC driver has not been updated for many versions of VFP and does not support new data types and features. Use the OLE DB Provider instead. It will allow you to open the tables regardless of VFP version used...unless the DBC has database events turned on and those are looking for some public (global) variable to be set.

Craig Berntson
MCSD, Visual FoxPro MVP,
 
I had tried using the ole db driver. I am now trying this -

Provider=VFPOLEDB.1;Data Source=c:\;Password="";Collating Sequence=MACHINE

but I am now getting the error - Data source name not found and no default driver specified

 
I've found the problem. In my code I was using an ODBCConnection object, but trying to use an ole db driver.
I changed it to use an oledbdataadapter, and it works now.

Thanks for everyone's help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top