Paradox Tables in C#

12,364

Solution 1

I've had the same error. It appeared when I started my C# project on Win2008 64 (previos OS was Win2003 32). Also I found out that it worked fine in console apps and gave different errors in winforms. It seems that problem comes from the specifics of 32 ODBC driver working on 64-bit systems. My solution was:

// Program.cs
static void Main()
{
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        // it is important to open paradox connection before creating
        // the first form in the project
        if (!Data.OpenParadoxDatabase())
            return;
        Application.Run(new MainForm());
}

The connectionstring is common:

string connStr = @"Driver={{Microsoft Paradox Driver (*.db )}};DriverID=538;
                   Fil=Paradox 7.X;DefaultDir=C:\\DB;Dbq=C:\\DB;
                   CollatingSequence=ASCII;";

After opening connection you may close it in any place after creating first Form (if you need to keep DB closed most of time), for example:

private void MainForm_Load(object sender, EventArgs e)
{
    Data.CloseParadoxDatabase();
}

After doing that you may open and close connection every time you want during execution of your application and you willn't get any exceptions.

Solution 2

Try to Run all The Applications with the "Run As Administrator" privileges especially run the VS.NET with "Run As Administrator "... and I am sure your problem get solved

Solution 3

Maybe this will help you out,

http://support.microsoft.com/support/kb/articles/Q237/9/94.ASP?LN=EN-US&SD=SO&FR=1 http://support.microsoft.com/support/kb/articles/Q230/1/26.ASP

It appears that the latest version of the Microsoft Jet Database Engine

(JDE) does not fully support Paradox unless the Borland Database Engine

(BDE) is also installed.

Share:
12,364
Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin almost 2 years

    I'm trying to read a Paradox 5 table into a dataset or simular data structure with the view to putting it into an SQL server 2005 table. I've trawled google and SO but with not much luck. I've tried ODBC:

    public void ParadoxGet()
    {
        string ConnectionString = @"Driver={Microsoft Paradox Driver (*.db )};DriverID=538;Fil=Paradox 5.X;DefaultDir=C:\Data\;Dbq=C:\Data\;CollatingSequence=ASCII;";
    
        DataSet ds = new DataSet();
        ds = GetDataSetFromAdapter(ds, ConnectionString, "SELECT * FROM Growth");
        foreach (String s in ds.Tables[0].Rows)
        {
            Console.WriteLine(s);
        }
    }
    public DataSet GetDataSetFromAdapter(DataSet dataSet, string connectionString, string queryString)
    {
        using (OdbcConnection connection = new OdbcConnection(connectionString))
        {
            OdbcDataAdapter adapter = new OdbcDataAdapter(queryString, connection);
            connection.Open();
            adapter.Fill(dataSet);
            connection.Close();
        }
        return dataSet;
    }
    

    This just return the error

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

    I've also tired OELDB (Jet 4.0) but get the same External table is not in the expected format error.

    I have the DB file and the PX (of the Growth table) in the Data folder... Any help would be much appriciated.

  • Marc Meketon
    Marc Meketon about 12 years
    That worked for me. I do not understand Paradox well enough to know why that works. For example, I moved the location of the PDOXUSRS.NET file from C:\ to someplace where I thought everyone had permission, but that did not help to avoid the "run as administrator" solution.
  • dan-gph
    dan-gph over 9 years
    Another solution would be to simply set the Platform Target in the project properties to x86 (if it's appropriate to do so).