Month List

RecentComments

Comment RSS

Connecting to a PARADOX DB with C# (Vista, XP)

by Ioannis 28. November 2008 23:46

You have a Paradox DB deployed in C:\PARADOXDB\ and you want to connect through C#. Here are the steps that you need to follow:

  1. Dowload BDEInfo.exe which contains the Borland Database Engine (BDE 5.0.2) and a configuration utility.
  2. Install BDEInfo.exe. If no error occurs proceed to step 4. If you get an error message complaining the "BDE already is in memory...." proceed ot step 3.
  3. Locate either in C:\WINDOWS\TEMP\ or the Temp user's folder and locate any file named inmem###.rem and delete it. You need also to find whether there is a folder in C:\PROGRAM FILES\BORLAND\ which a contains a previous installation of BDE and erase it also.
  4. Now BDE is installed.
  5. Create within the C:\PARADOXDB\ folder a folder named LOCKFILES.
  6. Open BDEADMIN.EXE located in C:\PROGRAM FILES\BORLAND\BDE or your installation folder and go to Configuration/Drivers/Native/PARADOX and change the NET DIR entry to C:\PARADOXDB\LOCKFILES\.
  7. Go to Object and click Apply.
  8. Change the file permissions of the LOCKFILES folder for the user "NETWORK SERVICE" to full control.

Now the BDE engine is up and running and you are ready to connect. Create a new C# application and choose one of the following snippets.

To connect:

private bool OpenConnection()

      OleDbConnection _connection = new OleDbConnection(); 
      StringBuilder ConnectionString = new StringBuilder("");
      ConnectionString.Append(@"Provider=Microsoft.Jet.OLEDB.4.0;");
      ConnectionString.Append(@"Extended Properties=Paradox 5.x;");
      ConnectionString.Append(@"Data Source=C:\PARADOXDB\;");
      _connection.ConnectionString = ConnectionString.ToString();
      try { _connection.Open(); }
      catch (Exception e) { MessageBox.Show("Error openning database! "+e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return false; }
      return true;
}


To open a table in a datagridview (eg the table CLIENTS):

OpenConnection();
OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM CLIENTS;", <Connection object>);
DataSet dsRetrievedData = new DataSet();
da.Fill(dsRetrievedData);
this.dataGridView1.DataSource = dsRetrievedData;
this.dataGridView1.DataMember = dsRetrievedData.Tables[0].TableName;


Since the process of finding out what was wrong with connecting to the PARADOXDB took me some time there may be some steps that were useful and not mentioned here. Please leave a comment is this worked for you. If not I can suggest some other stuff I have tried and may have been also useful and forgot to mention them.

 kick it on DotNetKicks.com

Tags:

.NET | Databases

Comments (3) -

6/9/2010 9:43:53 AM #

Ludger Verlande

Thanks a lot for this wonderful solution. I was able to solve my problem with this. Especially the desciption of the settings of BDE were very good. It works fine.

Ludger Verlande Germany

11/2/2011 10:18:48 PM #

Mark Boshoff

I can't seem to update the Paradox db, getting this error: "Operation must use an updateable query." Any ideas?

Mark Boshoff

1/2/2012 9:51:24 PM #

Przemysław Staniszewski

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.

Przemysław Staniszewski

Pingbacks and trackbacks (1)+

Add comment




biuquote
  • Comment
  • Preview
Loading






Powered by BlogEngine.NET 2.0.0.36

ITPRO DevConnections 2011

Creative Commons License

Programming Blogs - BlogCatalog Blog Directory Add to Technorati Favorites

MVP Award


Ioannis Panagopoulos





This blog is using BlogEngine.Net and is hosted in the hoster below. I have not experienced any problems installing BlogEngine.Net in the host and I am satisfied with the host's response times. Therefore I recommend it.


DiscountASP Add