T
Tony
Hello everyone,
I am using the Access.Application class in my program to import external
data from an excel spreadsheet to my access DB, it's working fine on any
system that has Office 2002 installed, but will throw an exception when it's
running on a machine that has Office 2000 on it... Does anyone know any way
to get around this?
Thanks in advance
Here is my piece of code:
Access.ApplicationClass access = new Access.ApplicationClass();
try
{
string dbPath = db.getDbPath();
string table = "tblBookTitle";
access.OpenCurrentDatabase(dbPath, false, "");
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
string file = openFileDialog1.FileName.ToString();
access.DoCmd.TransferSpreadsheet
(Access.AcDataTransferType.acImport,
Access.AcSpreadSheetType.acSpreadsheetTypeExcel9, table, file, true, null,
null);
MessageBox.Show("Import Successful");
}
}
access.CloseCurrentDatabase();
access = null;
}
catch (Exception exc)
{
MessageBox.Show(exc.Message.ToString());
access.CloseCurrentDatabase();
access = null;
}
I am using the Access.Application class in my program to import external
data from an excel spreadsheet to my access DB, it's working fine on any
system that has Office 2002 installed, but will throw an exception when it's
running on a machine that has Office 2000 on it... Does anyone know any way
to get around this?
Thanks in advance
Here is my piece of code:
Access.ApplicationClass access = new Access.ApplicationClass();
try
{
string dbPath = db.getDbPath();
string table = "tblBookTitle";
access.OpenCurrentDatabase(dbPath, false, "");
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
string file = openFileDialog1.FileName.ToString();
access.DoCmd.TransferSpreadsheet
(Access.AcDataTransferType.acImport,
Access.AcSpreadSheetType.acSpreadsheetTypeExcel9, table, file, true, null,
null);
MessageBox.Show("Import Successful");
}
}
access.CloseCurrentDatabase();
access = null;
}
catch (Exception exc)
{
MessageBox.Show(exc.Message.ToString());
access.CloseCurrentDatabase();
access = null;
}