Внешняя таблица не в ожидаемом формате в C # - после развертывания - PullRequest
0 голосов
/ 28 января 2019

Когда я пытаюсь прочитать лист Excel (.xlsx) с помощью c #, он работает, но это может быть только режим отладки, т. Е. Когда я пытаюсь выйти из режима отладки Visual Studio, он работает, я получаю лист Excel иЯ побрился в БД.

Then I have deployed IIS server 6.1 and I tried into client system I'm getting 
an error like 


External table is not in the expected format.
Description: An unhandled exception occurred during the execution of the 
current web request. Please review the stack trace for more information 
about the error and where it originated in the code. 

Exception Details: System.Data.OleDb.OleDbException: External table is not 
in the expected format.

Source Error: 
  Line 339:            {
  Line 340:
  Line 341:                oledbConn.Open();

Мой вопрос

Why it's not working after deployment? 
I have tried the client and server machine(which I hosted) both I'm getting the same error

Мой код:

var connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filePath + ";Extended Properties=\"Excel 12.0;HDR=Yes;\"";

oledbConn.Open();
OleDbConnection oledbConn = new OleDbConnection(connString);

using (OleDbCommand cmd = new OleDbCommand("SELECT * FROM [Project Structure with DG No$]", oledbConn ))
{
    OleDbDataAdapter oleda = new OleDbDataAdapter();
    oleda.SelectCommand = cmd;
    DataSet ds = new DataSet();
    oleda.Fill(ds);
    dt = ds.Tables[0];
}

Спасибо!

...