ODBC.NET and Excel
-
Hello I want to open a Excel-file in ADO.NET as a DataSet. I downloaded the ODBC.NET. and made a DSN-file pointing to the excel-file. Then I made a connection to the DSN-file in the Server-explorer. So far so good. But when I try to use the generated connectionString opening a OleDbConnection. I get the following error: The .Net Data Ole DB Provider(System.Data.OleDb) does not support the MSDASQL Provider, Microsoft OLE DB Provider for ODBC Drivers. ----- My connectionString looks like this: Provider=MSDASQL.1;Persist Security Info=False;Extended Properties="DBQ=G:\costumers\foretag.xls;DefaultDir=G:\costumers;Driver={Driver do Microsoft Excel(*.xls)};DriverId=790;FIL=excel 8.0;FILEDSN=G:\costumers\foretag.dsn;MaxBufferSize=2048;MaxScanRows=8;PageTimeout=5;ReadOnly=0;SafeTransactions=0;Threads=3;UID=admin;UserCommitSync=Yes;" How do I do this?
-
Hello I want to open a Excel-file in ADO.NET as a DataSet. I downloaded the ODBC.NET. and made a DSN-file pointing to the excel-file. Then I made a connection to the DSN-file in the Server-explorer. So far so good. But when I try to use the generated connectionString opening a OleDbConnection. I get the following error: The .Net Data Ole DB Provider(System.Data.OleDb) does not support the MSDASQL Provider, Microsoft OLE DB Provider for ODBC Drivers. ----- My connectionString looks like this: Provider=MSDASQL.1;Persist Security Info=False;Extended Properties="DBQ=G:\costumers\foretag.xls;DefaultDir=G:\costumers;Driver={Driver do Microsoft Excel(*.xls)};DriverId=790;FIL=excel 8.0;FILEDSN=G:\costumers\foretag.dsn;MaxBufferSize=2048;MaxScanRows=8;PageTimeout=5;ReadOnly=0;SafeTransactions=0;Threads=3;UID=admin;UserCommitSync=Yes;" How do I do this?
The ODBC.NET installation includes a new namespace: Microsoft.Data.Odbc as opposed to System.Data.OleDb. You need to be opening an OdbcConnection instead of an OleDbConnection. If you want to add this to your toolbox, right-click the Data toolbox, select "Customize Toolbox", go to the .NET Framework Components tab and check the boxes next to the Odbc... objects. Paul