在C#中连接Excel throw odbc时出错

时间:2017-09-09 16:04:22

标签: c# excel odbc

在ODBC中连接Excel时出现此错误:

  System.Data.Odbc.OdbcException occurred
      HResult=0x80131937
      Message=ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
      Source=
      StackTrace:
    <Cannot evaluate the exception stack trace>

这是我的代码:

string ConnectionString = "Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};Dbq=" + path + ";";
            OdbcConnection cnn = new OdbcConnection();
            cnn.ConnectionString = ConnectionString;
            cnn.Open();

我已经安装了this驱动程序。

0 个答案:

没有答案