1

I'm looking for how to access a Paradox database with C#.

The problem is that, on workstation is all ready running program, which using target database. Until it's running, oleDbConnection.Open() throws an exception.

If I'm not running program in .NET from the same computer but in another Windows workstation and using shared folder all works fine. The original program has read/write access and I have read-only access as I need. Of course on the second computer NET DIR is pointing to the right directory in the shared folder.

If I use share folder and run both program (my and original) on the same computer and configure BDE to use the shared folder connection from C# to Paradox Database can't be opened.

I tried to run program from .NET on Administrator account rights but it doesn't help.

So I take one other program, Paradox database editor and try to edit one of tables when original program is running. On the user rights it give me error about accessing the network folder. But when running with administrator rights I can successfully read database, as well as when only Paradox database editor is running only on user account rights.

Bo Persson
  • 90,663
  • 31
  • 146
  • 203
  • IIRC you also need a 'private dir', have you made sure different (copies of) programs use different paths? – H H Jan 02 '12 at 12:49
  • It is not clear to me where I should define this 'private dir' for application. In BDE Administrator or in connection string for OleDbConnection. – Przemysław Staniszewski Jan 02 '12 at 18:26

1 Answers1

0

It sounds like you may be having problems with the Paradox locking mechanism. When Paradox (BDE in your case) accesses a table it places a lock of one type or another on the table by creating and making an entry in a special lock file in the table directory. These are controlled by a single Paradox.net file in a specific location.

I think you are saying that the current application is using BDE and you may be using something else. I'm not sure you can do that, but if you could, you would have to be using the same locking files and Paradox.net file. Also, you would have to be using the same paradox version logic. There was some change to this locking mechanism over several Paradox versions. Try to run each program separately and see what files it creates and where. They should be the same ones.

I don't think the private directory is as important. In fact, 2 users can not have the same private directory.

Patrick Moloney
  • 642
  • 5
  • 14
  • After Henk comment I dig in Google and found something interesting http://sgbd.developpez.com/PDox%20Survival%20Guide.rtf . In directory c:\application\ i have at last 2 dirs : PRIVDIR and MYDATA. Using original application in privdir are used PDOXUSRS.NET, Paradox.lck, PDOXUSRS.LCK, in MYDATA Paradox.lck, PDOXUSRS.LCK Querying with .NET Framework produces in privdir PDOXUSRS.NET, in MYDATA PDOXUSRS.LCK and PARADOX.LCK. So querying with .NET Framework doesn’t produce Paradox.lck, PDOXUSRS.LCK in PRIVIR. Applications was run separately. How to specify private directory for .NET queries? – Przemysław Staniszewski Jan 05 '12 at 14:37
  • Here is how to set up private directory http://www.progware.org/Blog/post/Connecting-to-a-PARADOX-DB-with-C-%28Vista-XP%29.aspx but also changing location of .NET file. Quote from the previous link: Concurrency In a multi-user environment, the Paradox 4.0 locking protocol maintains concurrency (the simultaneous use of applications) through the PDOXUSRS.NET file. All users who want to share Paradox tables must map to the same PDOXUSRS.NET file in the same way using the same path, but not necessarily the same drive letter. – Przemysław Staniszewski Jan 06 '12 at 11:37
  • Yes, every application and every user should be using the one Pdoxusrs.net file. This file controls the multi-user access. It does that by creating 2 .lck files on each table that is accessed. But it also deletes those .lck files when the users finish with the tables - so you should not have .lck files on your system. If you do, and no one is running those apps, you can delete them. And you should because something has not finished and cleaned up properly, and they will cause problems. – Patrick Moloney Jan 08 '12 at 01:06
  • Also, Paradox does not create .lck files in your private directory - so you have something wrong there too. You should not have real, shared tables in your private directory. And both applications should specify the same private directory. I have no idea how to specify the private directory when using MS dot net. However, you can see what it is using, then change your Paradox private dir to that, and they will be the same. The private dir should usually be on your local drive (c:), for performance purposes. – Patrick Moloney Jan 08 '12 at 01:06
  • I did not have enough time, but I checked this. After setting NET DIR in BDE (which was run on administrator rights), .NET application use new directory to place/use Pdoxusrs.net file. So I configure original application to use this new private directory. Unfortunately they could not work in parallel. I don't try yet clear.LCK files manually in private directory. As you mention, in private directory there should not be any .lck files. As I wrote earlier .NET Framework doesn't produce .lck files in private directory. Original application dose. – Przemysław Staniszewski Jan 09 '12 at 21:15
  • I made at last one bug in code. After open connection to PARADOX database I call other functions witch are created SQL and after that run it on opened connection. So I get something like timeout but without clear message what was the reason. Of course the reason was ability to write Clean Code ;) . – Przemysław Staniszewski Mar 25 '12 at 08:33