0

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)

Remember it is running perfect locally from VS, when i deploying on IIS on same machine it giving error

2 Answers 2

0

You're trying to reference a DSN that hasn't been created yet it seems. You can create one of these by opening your Administrative Tools folder and then starting the Data Sources (ODBC) applet.
It seems like you'll then have to create a DSN called Excel Files, if you have a machine where this currently works you might be able to copy the settings from that machine.

0
0

You could do it the DSNless way by providing a path to the file. see this post:

http://weblogs.asp.net/rajbk/archive/2009/05/02/uploading-an-excel-file-to-sql-through-an-asp-net-webform.aspx

1
  • This article is really great , but what about the error. why it is coming. I think this error will come in your code also.
    – Red Swan
    May 4, 2010 at 11:58

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.