Ioannis Panagopoulos blog

Tutorials on HTML5, Javascript, WinRT and .NET

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

by Ioannis Panagopoulos

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

blog comments powered by Disqus
hire me