By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,670 Members | 1,330 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,670 IT Pros & Developers. It's quick & easy.

Reading Excel using Odbc

P: n/a
Hello, I need to read the excel file using Odbc, but when I run my code, I
got the following error:

"Error: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not
found and no default driver specified"

Could someone please tell me what is wrong with this?. Here is the code I
use to read the file.

I already include the Microsoft.Data.Odbc and add reference to Excel10.
Thank you

String sConnectionString = "Provider=MSDASQL;Driver={Microsoft Excel
Driver(*.xls)};DBQ=c:\\temp\\Sale_Test.xls;;;Exten ded

// Create connection object by using the preceding connection string.

objConn = new OdbcConnection(sConnectionString);

OdbcCommand objCmdSelect =new OdbcCommand();

objCmdSelect.Connection = objConn;

objCmdSelect.CommandText = "Select * From [Week1$]";

Nov 13 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.