0

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?

MRWonderFuXker
  • 203
  • 3
  • 19

1 Answers1

1

I'll bet that either/or

  • the ASP.Net worker process doesn't have access to C:\excFile.xlsx
  • Microsoft Excel is not installed on the server

This SO article may help.

Community
  • 1
  • 1
Richard Schneider
  • 34,944
  • 9
  • 57
  • 73