T
tbuffaloe
I have an Access 2003 format MDB with 530 of defined tables. The
tables have no data in them and on a machine that has office 2003 all
tables can be opened, and structure can be checked using Access 2003.
However, opening the same file (or a copy of the same file) on a
machine with office 2007 opens the MDB fine, but on some tables
results in Unrecognized database format error. Which happens to be the
last table definition that was added to the MDB.
If I use VS.NET to read the table structures the
OleDbDataAdapter.FillSchema will not return an error but does not
succeed in reading the same table that Access 2007 cannot reference.
FillSchema(oDS, SchemaType.Source, strTableName);
If Office 2007 is removed from the machine in question but Office 2003
remains the MDB behaves normally again.
Any ideas what is happening that affects the MDB, or how to avoid this
issue?
Sample code: that works on a machine with Office 2003 or earlier
versions.
/// DataExportObj - Constructor.
/// </summary>
/// <param name="oDS"> Output dataset</param>
/// <param name="strTableName"> Database table name</param>
public DataExportObj(ref DataSet oDS, string strTableName)
{
//
// Identify where the program was run from to find the export
reference database.
//
string codebasefile =
System.Reflection.Assembly.GetExecutingAssembly().Location;
m_strExePath = Path.GetDirectoryName(codebasefile);
m_strExePath = Path.Combine(m_strExePath, "CSVDef.mdb");
m_connGeneric = new OleDbConnection();
m_connGeneric.ConnectionString = "Jet OLEDB:Global Partial Bulk
Ops=2;Jet OLEDB:Registry Path=;Jet OLEDBatabase Locking Mode=1;Data
Source="
+ m_strExePath + ";Jet OLEDB:Engine Type=5;Jet OLEDB:Global Bulk
Transactions=1;Provider=\"Microsoft.Jet.OLEDB.4.0\";Jet
OLEDB:SFP=False;Mode=Share Deny None;Jet OLEDB:Create System
Database=False;Jet OLEDBon't Copy Locale on Compact=False;Jet
OLEDB:Compact Without Replica Repair=False;User ID=Admin;Jet
OLEDB:Encrypt Database=False";
m_connGeneric.Open();
AddTable(ref oDS, strTableName);
}
/// <summary>
/// AddTable - Add a table to the existing dataset.
/// </summary>
/// <param name="oDS"> Output dataset</param>
/// <param name="strTableName"> Database table name</param>
public void AddTable(ref DataSet oDS, string strTableName)
{
OleDbCommand selectCmd;
selectCmd = new OleDbCommand("SELECT * FROM " + strTableName,
m_connGeneric);
OleDbDataAdapter DAGeneric = new OleDbDataAdapter(selectCmd);
DAGeneric.FillSchema(oDS, SchemaType.Source, strTableName);
DAGeneric.Fill(oDS, strTableName); ///this is where the error
occurs with office 2007.
}
tables have no data in them and on a machine that has office 2003 all
tables can be opened, and structure can be checked using Access 2003.
However, opening the same file (or a copy of the same file) on a
machine with office 2007 opens the MDB fine, but on some tables
results in Unrecognized database format error. Which happens to be the
last table definition that was added to the MDB.
If I use VS.NET to read the table structures the
OleDbDataAdapter.FillSchema will not return an error but does not
succeed in reading the same table that Access 2007 cannot reference.
FillSchema(oDS, SchemaType.Source, strTableName);
If Office 2007 is removed from the machine in question but Office 2003
remains the MDB behaves normally again.
Any ideas what is happening that affects the MDB, or how to avoid this
issue?
Sample code: that works on a machine with Office 2003 or earlier
versions.
/// DataExportObj - Constructor.
/// </summary>
/// <param name="oDS"> Output dataset</param>
/// <param name="strTableName"> Database table name</param>
public DataExportObj(ref DataSet oDS, string strTableName)
{
//
// Identify where the program was run from to find the export
reference database.
//
string codebasefile =
System.Reflection.Assembly.GetExecutingAssembly().Location;
m_strExePath = Path.GetDirectoryName(codebasefile);
m_strExePath = Path.Combine(m_strExePath, "CSVDef.mdb");
m_connGeneric = new OleDbConnection();
m_connGeneric.ConnectionString = "Jet OLEDB:Global Partial Bulk
Ops=2;Jet OLEDB:Registry Path=;Jet OLEDBatabase Locking Mode=1;Data
Source="
+ m_strExePath + ";Jet OLEDB:Engine Type=5;Jet OLEDB:Global Bulk
Transactions=1;Provider=\"Microsoft.Jet.OLEDB.4.0\";Jet
OLEDB:SFP=False;Mode=Share Deny None;Jet OLEDB:Create System
Database=False;Jet OLEDBon't Copy Locale on Compact=False;Jet
OLEDB:Compact Without Replica Repair=False;User ID=Admin;Jet
OLEDB:Encrypt Database=False";
m_connGeneric.Open();
AddTable(ref oDS, strTableName);
}
/// <summary>
/// AddTable - Add a table to the existing dataset.
/// </summary>
/// <param name="oDS"> Output dataset</param>
/// <param name="strTableName"> Database table name</param>
public void AddTable(ref DataSet oDS, string strTableName)
{
OleDbCommand selectCmd;
selectCmd = new OleDbCommand("SELECT * FROM " + strTableName,
m_connGeneric);
OleDbDataAdapter DAGeneric = new OleDbDataAdapter(selectCmd);
DAGeneric.FillSchema(oDS, SchemaType.Source, strTableName);
DAGeneric.Fill(oDS, strTableName); ///this is where the error
occurs with office 2007.
}