The sample code below shows how my application connect to a .xlsx
file by OleDbConnection
. However, it works in console program but not in my asp page..
The worst things is the error message returned is
error: Unspecified error
try{
System.Data.OleDb.OleDbConnection MyConnection;
System.Data.OleDb.OleDbCommand myCommand = new System.Data.OleDb.OleDbCommand();
string sql = null;
MyConnection = new System.Data.OleDb.OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\excFile.xlsx;Extended Properties='Excel 12.0 Xml;HDR=NO';");
MyConnection.Open();
myCommand.Connection = MyConnection;
}
catch (Exception ex)
{
mydebug("error:" + ex.Message);
}
I have no idea how to handle an Unspecified error... Does any know how to connect oledb in asp page?