none
System.Data.OleDb.OleDbException: Unspecified error RRS feed

  • Question

  •  

    Hello,

     

    I have a web application and working in the Window Vista in Visual Studio 2005.  I have a code that read the database and it fails to open the database at myConnection.Open(); because of  "System.Data.OleDb.OleDbException: Unspecified error".  I checked the permission to the database and it has full control for all users to access to that database. If I run my web application as localhost in IIS, it fails to open the connection to the database and if I run my web application as development server with its port number, the connection to the database is working fine. 

     

    At first, I thougth the "sqloledb.dll" was not register to the Vista machine, so I registered the "sqloledb.dll" that and also try to run the 32-bit version of ASP.NET 2.0 as following these steps below but still doesn't help to solve the problem with the open connection in localhost .  So I'm wondering what cause the local server host fails to open the OLeDB connection to the access database.  Does anyone familiar with this problem and knows how to solve it?  Thanks

     

     To run the 32-bit version of ASP.NET 2.0 as following these steps:

    1. Click Start, click Run, type cmd, and then click OK.
    2. Type the following command to enable the 32-bit mode:
    cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 1
    3. Type the following command to install the version of ASP.NET 2.0 (32-bit) and to install the script maps at the IIS root and under:
    %SYSTEMROOT%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i
    4. Make sure that the status of ASP.NET version 2.0.50727 (32-bit) is set to Allowed in the Web service extension list in Internet Information Services Manager.

     

     

    Error:

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Data.OleDb.OleDbException: Unspecified error

    Source Error:

    Line 55:                 myCommand.Parameters.AddWithValue("", strUserName);
    Line 56:                 myCommand.Parameters.AddWithValue("", strPassword);
    Line 57:                 myConnection.Open();
    Line 58:                 retval = (int)myCommand.ExecuteScalar();
    Line 59:             }

     

     

    Thursday, June 5, 2008 2:08 PM

Answers

All replies

  • There are two things here you are running 64bits IIS 7 which needs to be configured to run in IIS6 mode in 32bits mode and if your database is Access then you need to reference MDAC in your code.  So if you are using Access let me know so I can help you.

     

     

     

    Thursday, June 5, 2008 2:28 PM
  •  

    Thanks Caddre for replying,

     

    Yes, I'm using OleDB for the acces database and here is my sample code for connecting to the database

     

    string SelectQuery = "Select Count(*) from Users Where username=? AND passwd = ?";
    string myConnString =  "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + ConfigurationManager.AppSettings.Get("UserDb");
    using (OleDbConnection myConnection = new OleDbConnection(myConnString))
    {
        using (OleDbCommand myCommand = new OleDbCommand(SelectQuery, myConnection))
        {
            myCommand.Parameters.AddWithValue("", strUserName);
            myCommand.Parameters.AddWithValue("", strPassword);
            myConnection.Open();                     //Fails to open the connection state and have error: "Unspecified error"
            int retval = (int)myCommand.ExecuteScalar();
        }
    }
    if(retval > 0 )
    {
        StrRetVal = "Valid User";


    }
    else
    {
         StrRetVal = "Error: Invalid User";


    }

    Thursday, June 5, 2008 3:08 PM
  • I don't need your code you just need to configure IIS7 in IIS6 mode and 32bits mode and run aspnet_regiis in your C drive.  Then manually add reference to MDAC because Vista comes with new data access component so it is not aware of the JET engine.

     

    http://blogs.technet.com/mbaher/archive/2006/12/17/running-iis-32-bit-applications-on-iis-64-bit.aspx


    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=974386&SiteID=1

     

    Thursday, June 5, 2008 4:13 PM
  •  

    Hi Caddre,

     

    Can you walk me through this on how to configure the IIS7 in IIS6 mode in Window Vista?  I ussually get used to work in the Window XP Professional. Recently,  I migrated all my projects from Window XP and work in Window Vista but have a lot of problem with setting up the web application runs in IIS7 in Vista machine.  Those problems had been solved and now I have the problem with the connecting to the access database. 

     

    I read the article that you gave at http://blogs.technet.com/mbaher/archive/2006/12/17/running-iis-32-bit-applications-on-iis-64-bit.aspx and it says that from the Inetpub admin scripts run the following script: "cscript.exe adsutil.vbs set W3SVC/AppPools/Enable32BitAppOnWin64 true"  So which "admin script" are they refering to?  I found this link at:  http://support.microsoft.com/default.aspx/kb/894435 and it shows you how to run IIS 32-bit version of ASP.NET 2.0 on IIS 64-bit and registered the aspnet_regiis afterward and I did that on the run command but it still doesn't help to solve problem with the open connection to the access db.  Maybe I'm missing something that I'm not aware of, Can you guide me through this?  Thankyou very much!

     

    Here is the step to enable the 32-bit mode that I found at http://support.microsoft.com/default.aspx/kb/894435 

    To run the 32-bit version of ASP.NET 2.0, follow these steps:

    1. Click Start, click Run, type cmd, and then click OK.
    2. Type the following command to enable the 32-bit mode:
    cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 1
    3. Type the following command to install the version of ASP.NET 2.0 (32-bit) and to install the script maps at the IIS root and under:
    %SYSTEMROOT%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i
    4. Make sure that the status of ASP.NET version 2.0.50727 (32-bit) is set to Allowed in the Web service extension list in Internet Information Services Manager.

    Thursday, June 5, 2008 6:06 PM
  • (I did that on the run command but it still doesn't help to solve problem with the open connection to the access db.  Maybe I'm missing something that I'm not aware of, Can you guide me through this? )

     

    It is not supposed to solve the connection to Access because it is the manual reference to MDAC I gave to you that solves connection to Access.  Read my post again I said you have two problems so add manual reference to MDAC and make sure you use Build option x86 or your code will not run. 

     

     

    Then we come to the IIS7 in IIS6 mode is covered by the Asp.net team in this visual configuration below before you run the commands for the 32bits enabling.

     

    http://blogs.msdn.com/webdevtools/archive/2006/09/18/developing-web-applications-on-windows-vista-with-visual-studio-2005.aspx

    Friday, June 6, 2008 12:32 AM