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!

Accessing FoxPro Database From Another Application

Status
Not open for further replies.

mccartmd

Programmer
Feb 3, 2003
63
US
Hello,

I have a FoxPro database that I am trying to update from a separate C# application. I'm using an OleDB connection to access the database, but if I have the database visible in FoxPro (i.e. simply looking at the list of tables in the project window), I get an exception saying the file can't be accessed.

I've tried setting Exclusive off by default, but it appears that the file is still in use by FoxPro.

Is there some setting that I can use on the database to make the file accessible to outside applications?

Thanks in advance for any help you can give.

Mike
 
Hi

You need to make sure that you set exclusive off BEFORE you open the database or tables in VFP - and you need to ensure that your VFP OLEDB calls are made with the exclusive off setting as well:

Code:
Provider=VFPOLEDB.1;Exclusive=No;Data Source=c:\myfolder\mydbc.dbc

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
make sure you set exclusive off in the vfp options, save that as default and if you reopen vfp, check if set("exclusive") really is off. You may have insufficient rights in the registry to save that setting as default, then you need to SET EXCLUSIVE OFF in each session of VFP, before openingn the project.

If exclusive is off, the project manager will still open dbfs exclusive, if you MODIFY a table, as that is needed to modify it, there is no way around this other than using the project manager responsible, eg not modify tables to take a look at their structure, but browse them and then use the modify from the data session window to get the modfiy table dialog in shared mode.

The best solution is to have a development/test and production version of the database, to not interfere with the application in the development.

Bye, Olaf.
 
As Olaf has suggested, your setting EXCLUSIVE OFF in your C# application is good to do, but more importantly is what the VFP application has SET EXCLUSIVE set to (ON or OFF).

If the VFP application is using the data table EXCLUSIVE, then your application's setting is moot - it still will not be able to access the table.

Good Luck,
JRB-Bldr
 
Thank you all for the quick responses!

It was the Set As Default that wasn't set after unchecking Exclusive in the options.

Now it works like a charm :)

Thanks again.

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top