error while reading Excel sheet

Posted by Lalit on Stack Overflow See other posts from Stack Overflow or by Lalit
Published on 2010-05-04T06:41:40Z Indexed on 2010/05/04 6:48 UTC
Read the original article Hit count: 249

Filed under:

Hi, I have code to read Excel from c3 language :

DataTable dtChildrenData = new DataTable(); OdbcConnection oConn = null; try { if (File.Exists(strSheetPath)) { oConn = new OdbcConnection(); oConn.ConnectionString = @"DSN=Excel Files;DBQ=" + strSheetPath + @";DriverId=1046;FIL=excel 12.0;MaxBufferSize=2048;PageTimeout=5;";

                OdbcCommand oComm = new OdbcCommand();
                oComm.Connection = oConn;
                oComm.CommandText = "Select * From [Sheet1$]";

                DataSet ds = new DataSet();
                OdbcDataAdapter oAdapter = new OdbcDataAdapter(oComm);
                oConn.Open();
                oAdapter.Fill(ds);
                dtChildrenData = ds.Tables[0];
            }
        }
        finally
        {
            oConn.Close();
        }
        return dtChildrenData;

But getting this error when i deploy the web application on IIS. Wherere as it is running fine locally.

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

How to solve this. Please let me know if any information required to answer this question (about configuration)

© Stack Overflow or respective owner

Related posts about excel