1

I develop .NET application (C#) and I need to read and update some data in a Paradox 7.x database.

According to Microsoft article for Paradox 7-8 no support is provided for OLEDB.

According to another SO question reading is possible, but not writing.

So is there any approach (maybe some third-party library or some BDE wrapper) how can I read and write to Paradox 7.x database?

UPDATE I've tried OleDB approach:

var builder = new OleDbConnectionStringBuilder();
builder.DataSource = "D:\\MyBase\\";
builder.Provider = "Microsoft.Jet.OLEDB.4.0";
var connection = new OleDbConnection(builder.ToString() + ";Extended Properties=Paradox 5.x");
var command = new OleDbCommand("SELECT * FROM Planes", connection);

connection.Open();
using (var reader = command.ExecuteReader())
     if (reader.HasRows)
         while (reader.Read())
               listBox1.Items.Add(reader.GetString(2));

This one fails with OleDbException (expectable because my database has Paradox 7.x format):

External table is not in the expected format

If I change connecton string to Extended Properties=Paradox 7.x - that one fails with enother OleDbException (expectable because Paradox 7 is not supported by OLEDB according to Microsoft article))

Invalid operation

I've tried ODBC approach:

var connectionString = "Driver={Microsoft Paradox Driver (*.db )};" 
                + "DriverID=538;Fil=Paradox 7.X;"
                + "DefaultDir=D:\\MyBase\\;"
                + "Dbq=D:\\MyBase\\;"
                + "CollatingSequence=ASCII;";

var connection = new OdbcConnection(connectionString);
var command = new OdbcCommand("SELECT * FROM Planes", connection);

connection.Open();
using (var reader = command.ExecuteReader())
      if (reader.HasRows)
            while (reader.Read())
                  listBox1.Items.Add(reader.GetString(2));

That one also fails with OdbcException

ERROR [HY000] [Microsoft] [Paradox ODBC driver] External table is not in the expected format

So nothing work nor now..

Darshan Dave
  • 645
  • 2
  • 9
  • 32
bairog
  • 3,143
  • 6
  • 36
  • 54
  • See if any of this helps: https://social.msdn.microsoft.com/Forums/vstudio/en-US/452c134f-cb37-4b12-88ad-ef18b877433f/paradox-7-reading-in-c?forum=csharpgeneral – Peter B Apr 03 '18 at 12:54
  • @PeterB I've tried all approaches - see **UPDATE** section – bairog Apr 03 '18 at 13:42
  • Then maybe this: https://www.connectionstrings.com/paradox/ – Peter B Apr 03 '18 at 13:46
  • @PeterB Tried from both **.NET Framework Data Provider for OLE DB** and **Microsoft Paradox Driver** sections - still same errors.. – bairog Apr 03 '18 at 13:57

1 Answers1

2

So finally I managed read and even write Paradox 7.x database via Microsoft.Jet.OLEDB.4.0 (decpite of Microsoft tells us that Paradox 7-8 is not supported):

  1. Install AccessDatabaseEngine for Office 2007 (32bit)
  2. Install AccessDatabaseEngine for Office 2010 (32bit) (choose AccessDatabaseEngine.exe)
  3. Install BDE 5.1.1.1 (It's better to install somewhere like D:\BDE)
  4. Via BDE Administrator change NET DIR from C:\ to any folder, where you have write privileges (I've changed to D:\BDE)

After following code works like a charm

var builder = new OleDbConnectionStringBuilder();
builder.Add("Provider", "Microsoft.Jet.OLEDB.4.0");
builder.Add("Data Source", @"D:\MyBase\");
builder.Add("Persist Security Info", "False");
builder.Add("Extended properties", "Paradox 7.x; HDR=YES");
var connection = new OleDbConnection(builder.Tostring()); 
var command = new OleDbCommand("SELECT * FROM Planes", connection);
//reading
connection.Open();
using (var reader = command.ExecuteReader())
     if (reader.HasRows)
         while (reader.Read())
               listBox1.Items.Add(reader.GetString(2));
//writing
command = new OleDbCommand("DELETE * FROM Planes", connection);
command.ExecuteNonQuery();
connection.Close();

Hope this information will help somebody like me.

bairog
  • 3,143
  • 6
  • 36
  • 54
  • 1
    Are Microsoft Access Database Engine 2007 and 2010 really needed here? I have BDE 5.1.1.1 and I can select data, but I have errors when trying to write to Paradox database: "Operation must use an updateable query" for insert, "Syntax error in UPDATE statement" for update, and "Could not delete from specified tables" for delete. – meir Oct 08 '20 at 11:28
  • 1
    @meir Well, it was 2.5 years ago :) You can follow my guide, as far as I remember I was able to write data. – bairog Oct 08 '20 at 15:12