1
votes

I’ve got some problem using an ODBC connection with IIS.
Here is my config :

  • IIS 5 on Windows XP
  • ASP.NET 2.0
  • Oracle 9
  • VS 2005

When I try too use my web application on IIS, I’ve got the following exception:
ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
BUT, when I use it like a web site in VS2005, I didn’t have any error.

So, I’d try to make a very little app, with the following code:

using System;
using System.Data;
using System.Data.Odbc;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        OdbcConnection con = new OdbcConnection();
        con.ConnectionString = "DSN=<MyDSN>;Uid=<LOGIN>;Pwd=<PASSWORD>";

        IDbCommand com = new OdbcCommand();
        com.CommandText = "select sysdate from dual;";
        com.CommandType = CommandType.Text;
        com.CommandTimeout = 30;
        com.Connection = con;

        try
        {
            con.Open();
            Response.Write(com.ExecuteScalar());
        }
        finally
        {
            if (con.State == ConnectionState.Open)
                con.Close();
        }
    }
}

It work fine on VS’s web server (ie: http://localhost:3715/Web/Default.aspx), but I’ve got the same exception (IM002) when I use it on IIS (ie: http://localhost/Tester/default.aspx).
My DSN is declared on the “ODBC Data Source Administrator” and work well when I test the connection…

The ASPNET account is in the same group as my user account (Administrators).
Full right for ASPNET Account on HKEY_LOCAL_MACHINE\SOFTWARE\ODBC and HKEY_CURRENT_USER\Software\odbc keys.
I've read this post, but nothing work...

I'd look after an answer on stackoverflow (search, related questions, etc.), google...but I didn't found a working solution...
Is there anyone who have an idea?...
Where is my mistake?...

UPDATE: 2011/04/06
What I’ve done so far:

  • Tracing for ODBC: on VS’Web server, I got log; but on IIS, none...
  • System and User DSN are filled with the same information
  • Allow ASPNET, IUSR_XXX, IWAN_XXX, and all users (sic…) accounts full rights to: %ORACLE_HOME%, HKEY_LOCAL_MACHINE\SOFTWARE\ODBC, HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE

Windows, VS and IIS are all for 32 bits (so, there is no c:\windows\syswow64).

Check PATH value, and put %ORACLE_HOME% first.

IIS was reset each time I do a modification, my computer reboot twice.

But, now, I’ve got this message:
ERROR [IM003] Specified driver could not be loaded due to system error 998 (Oracle dans OraHome92).

And I finally found... The administrators have install all the drivers in order to be used by the user only...
I’d create a system env var ORACLE_HOME...
There was only a user var :s

Thanks for your help.
I validate the Garry M. Biggs' answer because of the difference between system/user...

3

3 Answers

1
votes

Make sure you have created a System DSN rather than a User DSN.

IIS will be running as a System service and therefore does not have access to User registry entries...

2
votes

Had this problem ..
The best solution is to re install your odbc driver ... worked for me ..
the registry entries in your system might have got tampered .

I did a complete uninstall and re install .. worked for me .. lame but quick solution .

1
votes
  1. Maybe your system is 64 bit version of Windows and IIS is 64 bit, but VS is 32 bit? If so, look at my answers: odbc connection string dosen't work on windows 7

  2. If you can connect from one environment and not from the other then enable ODBC tracing and compare log files. MS described it at: http://support.microsoft.com/kb/274551