连接Excel错误在C#中抛出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();
我已经安装了这个驱动。