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

12/20/2008 10:56:16 AM #

trackback

Trackback from DotNetKicks.com

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

DotNetKicks.com

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

Add comment


(Will show your Gravatar icon)

Enter the word
CAPTCHA word
Add 1 to the number above


  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.5.0.7

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