1

My intention here is to render the excel data in a table, using a datatable, so opened an odbc connection and loaded the datatable like this:

System.Data.Odbc.OdbcConnection conn = new System.Data.Odbc.OdbcConnection(Dsn=Excel Files;Driver={Microsoft Excel Driver (*.xls)};Driverid=790;Dbq=C:\Users\*******\Documents\Book1.xlsx;DefaultDir=C:\Users\******\Documents;HDR=YES);
conn.Open();
DataTable dataTable = new DataTable();
string con = "select * from [sheet1$]";
System.Data.Odbc.OdbcCommand cmd = new System.Data.Odbc.OdbcCommand(con, conn);
System.Data.Odbc.OdbcDataReader dr = cmd.ExecuteReader();
dataTable.Load(dr);

But insted getting an error like this

ERROR [IM014] [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application

So actually whats' the root cause ?

2

2 Answers 2

2

Please use the following link as a possible solution to your problem:

ERROR [IM014] [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application

Sign up to request clarification or add additional context in comments.

4 Comments

now everything fine , but when I establish a connection with same connection string above , I got this error "ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified "
I got the way , yes I was using the DSN which was not found in the ODBC server , so I created the DSN and then utilized it .
Great, glad I could assist!
Creating a x86 Excel DSN worked for me. Used ODBC Admin to create new "Excel Files x86" DSN. Worked like a charm!
0

This suggests

"changing the Platform target project setting from Any CPU to x86."

will help. The root cause is, as the error says, a mismatch between the database driver and your application.

These docs say

If you use the 64-bit odbcad32.exe to configure or remove a DSN that connects to a 32-bit driver, for example, Driver do Microsoft Access (*.mdb), you will receive the following error message: The specified DSN contains an architecture mismatch between the Driver and Application To resolve this error, use the 32-bit odbcad32.exe to configure or remove the DSN.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.