I’m writing an small software that will be part of an existing application which uses dbf foxpro tables. My application just reads 2 tables fill a dataset and closes the connection, pretty fast and simple. It works until one of those tables are being used or by foxpro itself (when the table is opened) or by the main application when it is accessing that table.
When it happens a get the exception
ex = {“Cannot open file c:\data\myFile.dbf.”} ErrorCode = -2147217865
Is it possible to specify that I want to access it just for reading, not editing?
PS: I’m using VS 2008 C# to access it. My connection string looks like: “Provider=VFPOLEDB.1;Data Source=C:\data\”
Many thanks
I am making an assumption when you are referring to “FoxPro itself” you mean someone is running FoxPro 2.6 for DOS or Windows, or Visual FoxPro (any version). If this is the case make sure the user uses the following command in the Command Window
Or they can open each table and include the SHARED clause on each USE command.
If you are referring to an application developed in FoxPro running against the data you have a slightly more complex situation because the app could be designed to be single user and have a SET EXCLUSIVE ON in the code. The best shot you have in this case is to try modify an existing Config.FP or Config.FPW (depending on the version) and adding a line:
Or you can create the file if it does not exist. If that does not work you would need the application source code to change it so it does not open tables exclusively.
As for your use of the VFP OLE DB driver with your C# program, you can include a Config.FPW file in the folder with the EXCLUSIVE = OFF and it will ensure you open the files in shared mode, just in case you are attempting exclusive use. This unlikely since the runtime version does not default to exclusive being on and the OLE DB driver is following the runtime standard.
Rick Schummer VFP MVP