Paradox tables in C #
I am trying to read a Paradox 5 spreadsheet in a dataset or simulated data structure to represent it in a SQL Server 2005 spreadsheet. I have trawled Google and SO but have not had 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 returns an error
ERROR [HY000] [Microsoft] [ODBC Paradox Driver] The external table is not in the expected format.
I got tired of OELDB (Jet 4.0) too, but getting the same external table not in expected format error.
I have a DB and PX (growth tables) file in the Data folder ... Any help would be multifaceted.
I had the same error. It appeared when I started a C # project on Win2008 64 (the previous OS was Win2003 32). Also I found out that it worked fine in console applications and gave different errors in winforms. It looks like the issue is related to the specification of a 32-bit ODBC driver that works 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());
}
Connection frequency:
string connStr = @"Driver={{Microsoft Paradox Driver (*.db )}};DriverID=538;
Fil=Paradox 7.X;DefaultDir=C:\\DB;Dbq=C:\\DB;
CollatingSequence=ASCII;";
After opening the connection, you can close it anywhere after the first form is created (if you need to keep the DB closed most of the time), for example:
private void MainForm_Load(object sender, EventArgs e)
{
Data.CloseParadoxDatabase();
}
After that, you can open and close the connection whenever you want during the execution of your application and you won't get any exceptions.
Maybe this will help you,
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 looks like the latest version of Microsoft Jet Database Engine
(JDE) does not fully support Paradox unless Borland Database Engine
(BDE).
Try to run all applications with "Run as administrator" privileges, especially start VS.NET with "Run as administrator" ... and I'm sure your problem will be solved.
This is not an answer, but more of a question: What specific reason are you trying to use C # to manipulate data, rather than using SQL Server tools to load data directly? Something like DTS or SSIS will seem like the best tool for the job.
Thanks, I'll try. I wanted to use C # so that I can put it on some web pages without having to add it to SQL server.