Link to home
Create AccountLog in
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();
            }  
 User generated image User generated image
Avatar of sammySeltzer
sammySeltzer
Flag of United States of America image

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

Avatar of AnandSahoo
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.


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


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
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.
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;
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?
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();
==========================

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();
after Changing it to ODBC, I am getting folowing error.

Screenshot3.JPG
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
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
ASKER CERTIFIED SOLUTION
Avatar of godeschalk
godeschalk
Flag of Netherlands image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
and maybe this is a solution http://exceldatareader.codeplex.com/
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
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



Thanks to godeschalk
U r a Star