Avatar of AnandSahoo
AnandSahoo
 asked on

IIS Error while browsing for the publised website on the 2003 x64 server

Dear Team,

Attached 2 error screenshot.
Screenshot1 - While accessing from any other client machine
Screenshot2 - While right click and click browse on in IIS website itself.

Have developed a simple asp.net website which access the Automatically generated Excel file and shows the data in gridview.

After configuring the IIS 6.0 in the server and publishing the website when I try to access the page I am getting above errors.

However its running absolutely fine on the local PC where its developed.

The server is running Windows server 2003 enterprise x64 edition.
IIS 6.0

Below is the code used....
-----------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
using System.Data;

namespace SOLUTIONSUPPORT
{
    public partial class FCR : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           

            System.IO.FileInfo file = new System.IO.FileInfo("C:\\dcs\\ssfcr.xls");
            string Dat = Convert.ToString("Status As On: " + file.LastWriteTime);
            Label1.Text = Dat;        
               
                // Create connection string variable. Modify the "Data Source"
                // parameter as appropriate for your environment.
                String sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
                    "Data Source=C:\\dcs\\ssfcr.xls;" +
                    "Extended Properties=Excel 8.0;";

                // Create connection object by using the preceding connection string.
                OleDbConnection objConn = new OleDbConnection(sConnectionString);

                // Open connection with the database.
                objConn.Open();

                // The code to follow uses a SQL SELECT command to display the data from the worksheet.

                // Create new OleDbCommand to return data from worksheet.
                OleDbCommand objCmdSelect = new OleDbCommand("Select * From [Sheet1$]", objConn);

                // Create new OleDbDataAdapter that is used to build a DataSet
                // based on the preceding SQL SELECT statement.
                OleDbDataAdapter objAdapter1 = new OleDbDataAdapter();

                // Pass the Select command to the adapter.
                objAdapter1.SelectCommand = objCmdSelect;

                // Create new DataSet to hold information from the worksheet.
                DataSet objDataset1 = new DataSet();

                // Fill the DataSet with the information from the worksheet.
                objAdapter1.Fill(objDataset1, "XLData");

                // Bind data to DataGrid control.
                grid_ssfcr.DataSource = objDataset1.Tables[0].DefaultView;
                grid_ssfcr.DataBind();

                // Clean up objects.
                objConn.Close();
            }  
 Screenshot1 Screenshot2
Microsoft IIS Web Server

Avatar of undefined
Last Comment
AnandSahoo

8/22/2022 - Mon
sammySeltzer

Your issue may be that the datasource you are using is not recognized or compatible with 64bit OS.

You may need to change the target platform.

See this link:

http://social.technet.microsoft.com/Forums/en-US/w7itproappcompat/thread/10f14ccf-0680-450f-8d49-54c06d0fe54f

AnandSahoo

ASKER
I searched this and found this in google before.
I am using Visual Studio 2008 express edition and did the same changes.
Published after rebuilding the application but getting the same page.
Restarted IIS service many times as well.


sammySeltzer

Hmm, have you tried using regsvr32 with  the five dll's under the Jet 4.0 OLD DB provider by following this link?

http://support.microsoft.com/kb/278604


Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
AnandSahoo

ASKER
Dear sammy,

I have 2 folders.
Program Files & Program files (x86)
In the both the folder I could not find the dll files mentioned under Jet 4.0 OLD DB.
How can I get those dll's and register it ?
Microsoft Jet 4.0 OLE DB Provider
Provider=Microsoft.Jet.OLEDB.4.0
C:\WINNT\System32\Msjetoledb40.dll
C:\WINNT\System32\Msjet40.dll
C:\WINNT\System32\Mswstr10.dll
C:\WINNT\System32\Msjter40.dll
C:\WINNT\System32\Msjint40.dll
AnandSahoo

ASKER
I found the files under C:\windows\Syswow64 folder instead of Program files.
Ran the regsvr32 command.

First 2 dll's showed as registerd successfully.
But rest did not. Error was Loaded but could not be registered.
godeschalk

By My knowledge Microsoft.Jet.OLEDB.4.0 provider is not 64-bit compatible, there are beta updates. But these also didin't work by me.

did youals looked at http://www.connectionstrings.com/excel#p116
.NET xlReader for Microsoft Excel
with header row
Data Source =c:\myExcelFile.xls;HDR=yes;Format=xls;

without header row
Data Source =c:\myExcelFile.xls;HDR=yes;Format=xls;
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
AnandSahoo

ASKER
Hi,

I think by putting HDR = Yes/No, We are telling ASP to read the first line in excel as header or not.
But will this help in getting rid of this error?
godeschalk

well to get rid of the Microsoft.Jet.OLEDB.4.0 provider error, you will have to set your applicatoin to only x86 system instead of any cpu. (because Microsoft.Jet.OLEDB.4.0 provider is not x64 compitble)

and i would also change the string of your connection instead of hard coded C:\\dcs\\ssfcr.xls i would use server.mappath instead.

you also could set iis to only work in 32bit mode to get rid of the error

and you could also try the System.Data.Odbc.OdbcConnection
================
using System.Data.Odbc;

string myConnectionString = "Driver={Microsoft Excel Driver (*.xls)};DriverId=790;Dbq=C:\MyExcel.xls;"DefaultDir=c:\mypath;

OdbcConnection myConnection = new OdbcConnection();
myConnection.ConnectionString = myConnectionString;
myConnection.Open();
==========================

godeschalk

here an complete example how to use odbc
using System.Data.Odbc;

OdbcConnection myConnection = new OdbcConnection();
        string myConnectionString = "Driver={Microsoft Excel Driver (*.xls)};DriverId=790;Dbq=" + Server.MapPath("MyExcel.xls") + ";DefaultDir=c:\mypath;";
        myConnection.ConnectionString = myConnectionString;
        myConnection.Open();
        OdbcDataAdapter da = new OdbcDataAdapter("Select * FROM [Sheet1$]", myConnection);
        DataSet ds = new DataSet();
        da.Fill(ds);
        GridView1.DataSource = ds;
        GridView1.DataBind();
        myConnection.Close();
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
AnandSahoo

ASKER
after Changing it to ODBC, I am getting folowing error.

Screenshot3.JPG
godeschalk

can you post your code and the excel file, looks like you haven't adjust the connection string and it can find the excel file
AnandSahoo

ASKER
Here is the code.
Its working while running on local pc, on th eserver I am getting above error.

Attached the
namespace SOLUTIONSUPPORT
{
    public partial class FCR : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
                         
            String sConnectionString = "Driver={Microsoft Excel Driver (*.xls)};DriverId=790;Dbq=C:\\dcs\\ssfcr.xls;ReadOnly=0;DefaultDir=c:\\dcs";

                  OdbcConnection objConn = new OdbcConnection(sConnectionString);

                objConn.Open();

                OdbcCommand objCmdSelect = new OdbcCommand("Select * From [Sheet1$]", objConn);
                OdbcDataAdapter objAdapter1 = new OdbcDataAdapter();

                objAdapter1.SelectCommand = objCmdSelect;

                DataSet objDataset1 = new DataSet();

                objAdapter1.Fill(objDataset1, "XLData");

                grid_ssfcr.DataSource = objDataset1.Tables[0].DefaultView;
                grid_ssfcr.DataBind();

                objConn.Close();
            }  
ssfcr.xls
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER CERTIFIED SOLUTION
godeschalk

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
godeschalk

and maybe this is a solution http://exceldatareader.codeplex.com/
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
AnandSahoo

ASKER
Looks Like we made it.
Have tried teh folowing
cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 1
then
C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i -enable
then
search for the <compiler tag and add  compilerOptions="/platform:x86"  to it.
and its working perfectly now.
no matter its jet oledb or odbc connection string.
Thank You



AnandSahoo

ASKER
Thanks to godeschalk
U r a Star
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck