Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: TNS could not resolve the connect identifier

Re: TNS could not resolve the connect identifier

From: Charles Hooper <hooperc2000_at_yahoo.com>
Date: 22 Nov 2006 17:33:34 -0800
Message-ID: <1164245614.028073.133040@e3g2000cwe.googlegroups.com>


antonyliu2002_at_yahoo.com wrote:
> I've searched this group before I decided to post this question,
> fearing being humiliated again by the notorious super Oracle DBA from
> the Netherlands whose last name is Bakker. Mr. Bakker, please stop
> right here immediately.
>
> I am not a database person, I do web development with ASP.NET 2.0 for
> IIS.
>
> The backend database for my web application is Oracle 10.1.0.2.0.
>
> This database resides on Machine A.
> The Web server is running on Machine B.
> I am developing the web application on Machine C.
>
> >From within Visual Web Developer 2005 Express on Machine C, I
> successfully configured the database connection. So, from the
> development machine, the web application works great, and the ListBox
> gets populated with data from the Oracle database nicely.
>
> But, if I check out this web application from the web sever on Machine
> B, I get the following error:
>
> <error>
> System.Data.OleDb.OleDbException: ORA-12154: TNS:could not resolve the
> connect identifier specified.
> </error>
>
> And the following the portion for connectionString in web.config for
> this web application:
>
> <connectionStrings>
> <add name="MyOracleConnectionString"
> connectionString="Provider=MSDAORA.1;Data Source=MyDataSource;Persist
> Security Info=True;Password=MyPassword;User ID=MyUserID"
> providerName="System.Data.OleDb" />
> </connectionStrings>
>
> I can tnsping mydatabase with no problem on both the development
> machine (Machine C) and the productive web server (Machine B). So, I
> guess this issue is probably not related to the TNSNAME setting.
>
> Is it because the same database provider is not installed on the
> productive web server (Machine B)? Would you kindly share your wisdom
> please? Thanks.

Sybrand Bakker seems to be very willing to help those people who have made a concerted effort to solve problems (such as performing a search as you have done), but he seems to have little patience for answering the same simple questions day after day. For good or bad, this helps reduce the number of simple questions submitted to the group, and allows questions other than those for which RTFM is the standard answer. I am not defending his responses, just an observation.

I have experience with ASP code writing on for IIS against Oracle databases, although I have not had much time to dig into ASP.NET 2.0. I had previously experiemented with Frontpage 2000, trying to set up an ASP page to automatically retrieve data and place it into an HTML table. It worked on my computer, but would not work when moved to the IIS server. I found that since I was running the 10.2.0 Oracle client on the development, the wizard in FrontPage collected information that was specific to the Oracle 10.2.0 client. Moving the ASP page to the server caused problems, as it was running the Oracle 8.0.5 client. I did not spend much time investigating the problem, since I already had a much more flexible working solution that was developed four years earlier.

This is what the DB connection looks like in my ASP pages, ASP.NET 2.0 should be similar:
<%

    dim dbConnect
    set dbConnect = Server.CreateObject("ADODB.Connection")

    dbConnect.Open "Provider=MSDAORA.1;User ID=" & session("Username") & ";Password=" & session("Password") & ";Data Source=DB_SID_HERE;Persist Security Info=True"

Note that the above pulls the session user name and password from session variables that were set in another ASP page. The IIS server, in addition to requiring the Oracle client, will also require some version of MDAC, likely 2.8 or later. The above code will work with Oracle clients 8.0.5, 8.1.7, and 10.2.0 without change.

Charles Hooper
PC Support Specialist
K&M Machine-Fabricating, Inc. Received on Wed Nov 22 2006 - 19:33:34 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US