Oracle Connection Problem with Microsoft .NET Provider for ORACLE

G

Guest

I am trying to connect to Oracle 9i Database from Windows Service. This is the connection string
User ID = ...;Password = ...;Data Source = ..

And I am getting an error

"ORA-12154: TNS:could not resolve service name\n

I tried changing Windows user name under which the service is running, doesn't help. Also when I run the same code from Windows Forms application everything works OK. I can connect to this server using SQL+. I am using .NET Framework 1.
Please help
 
D

David Browne

Andrew said:
I am trying to connect to Oracle 9i Database from Windows Service. This is the connection string :
User ID = ...;Password = ...;Data Source = ...

And I am getting an error:

"ORA-12154: TNS:could not resolve service name\n"

I tried changing Windows user name under which the service is running,
doesn't help. Also when I run the same code from Windows Forms application
everything works OK. I can connect to this server using SQL+. I am using
..NET Framework 1.1
Please help.

Reboot.

There are several environment variables which affect TNS name resolution.
Any changes to system environment variables will not be visible to the
service until after a reboot.

David
 
P

Paul Clement

¤ I am trying to connect to Oracle 9i Database from Windows Service. This is the connection string :
¤ User ID = ...;Password = ...;Data Source = ...
¤
¤ And I am getting an error:
¤
¤ "ORA-12154: TNS:could not resolve service name\n"
¤
¤ I tried changing Windows user name under which the service is running, doesn't help. Also when I run the same code from Windows Forms application everything works OK. I can connect to this server using SQL+. I am using .NET Framework 1.1
¤ Please help.

This would indicate to me that the account under which your service is running cannot see the
tnsnames.ora configuration file.


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
J

Joe Fallon

I got this once because I was running both Oracle 8 and 9i on the same
server.
Even though I specified the tnsnames file in the 9i folder, the code kept
looking in the 8 folder.
So I copied the settings to the folder and it worked.
Then I uninstalled 8!!
--
Joe Fallon



Andrew said:
I am trying to connect to Oracle 9i Database from Windows Service. This is the connection string :
User ID = ...;Password = ...;Data Source = ...

And I am getting an error:

"ORA-12154: TNS:could not resolve service name\n"

I tried changing Windows user name under which the service is running,
doesn't help. Also when I run the same code from Windows Forms application
everything works OK. I can connect to this server using SQL+. I am using
..NET Framework 1.1
 
R

Roy Fine

Paul Clement said:
¤ I am trying to connect to Oracle 9i Database from Windows Service. This is the connection string :
¤ User ID = ...;Password = ...;Data Source = ...
¤
¤ And I am getting an error:
¤
¤ "ORA-12154: TNS:could not resolve service name\n"
¤
¤ I tried changing Windows user name under which the service is running,
doesn't help. Also when I run the same code from Windows Forms application
everything works OK. I can connect to this server using SQL+. I am using
..NET Framework 1.1
¤ Please help.

This would indicate to me that the account under which your service is running cannot see the
tnsnames.ora configuration file.

Nope - it indicates that the instance identified by the SERVICE_NAME
parameter in the tnsnames.ora file was not found by the listener server
runnning the machine identified by the HOST parameter.

this from OTN:

ORA-12154: TNS:could not resolve service name

Cause: Oracle Net could not locate the net service name specified in the
tnsnames.ora configuration file.

Action: Perform these steps:

1.. Verify that a tnsnames.ora file exists.
2.. Verify that there are not multiple copies of the tnsnames.ora file.
3.. In the tnsnames.ora file, verify that the net service name specified
in your connect string is mapped to a connect descriptor.
4.. Verify that there are no duplicate copies of the sqlnet.ora file.
5.. If you are using domain names, verify that your sqlnet.ora file
contains a NAMES.DEFAULT_DOMAIN parameter. If this parameter does not exist,
you must specify the domain name in your connect string.
6.. If you are not using domain names, and this parameter exists, delete
it or disable it by commenting it out.
7.. If you are connecting from a login dialog box, verify that you are not
placing an "@" symbol before your connect net service name.
8.. Activate client tracing and repeat the operation.

Cause: Oracle Net could not locate the database service name or net service
name specified in the directory server.




regards
roy fine
 
P

Paul Clement

¤
¤ ¤ > On Thu, 6 May 2004 14:56:07 -0700, Andrew
¤ >
¤ > ¤ I am trying to connect to Oracle 9i Database from Windows Service. This
¤ is the connection string :
¤ > ¤ User ID = ...;Password = ...;Data Source = ...
¤ > ¤
¤ > ¤ And I am getting an error:
¤ > ¤
¤ > ¤ "ORA-12154: TNS:could not resolve service name\n"
¤ > ¤
¤ > ¤ I tried changing Windows user name under which the service is running,
¤ doesn't help. Also when I run the same code from Windows Forms application
¤ everything works OK. I can connect to this server using SQL+. I am using
¤ .NET Framework 1.1
¤ > ¤ Please help.
¤ >
¤ > This would indicate to me that the account under which your service is
¤ running cannot see the
¤ > tnsnames.ora configuration file.
¤ >
¤
¤ Nope - it indicates that the instance identified by the SERVICE_NAME
¤ parameter in the tnsnames.ora file was not found by the listener server
¤ runnning the machine identified by the HOST parameter.
¤
¤ this from OTN:
¤
¤ ORA-12154: TNS:could not resolve service name
¤
¤ Cause: Oracle Net could not locate the net service name specified in the
¤ tnsnames.ora configuration file.
¤
¤ Action: Perform these steps:
¤
¤ 1.. Verify that a tnsnames.ora file exists.
¤ 2.. Verify that there are not multiple copies of the tnsnames.ora file.
¤ 3.. In the tnsnames.ora file, verify that the net service name specified
¤ in your connect string is mapped to a connect descriptor.
¤ 4.. Verify that there are no duplicate copies of the sqlnet.ora file.
¤ 5.. If you are using domain names, verify that your sqlnet.ora file
¤ contains a NAMES.DEFAULT_DOMAIN parameter. If this parameter does not exist,
¤ you must specify the domain name in your connect string.
¤ 6.. If you are not using domain names, and this parameter exists, delete
¤ it or disable it by commenting it out.
¤ 7.. If you are connecting from a login dialog box, verify that you are not
¤ placing an "@" symbol before your connect net service name.
¤ 8.. Activate client tracing and repeat the operation.
¤
¤ Cause: Oracle Net could not locate the database service name or net service
¤ name specified in the directory server.
¤

Since he can access Oracle via SQL Plus I don't believe it is a tnsnames.ora configuration issue.
It's more than likely a system or application configuration problem.

The problem with this error is that there can be any number of problems that can cause it to occur.


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
J

Joe Fallon

Paul,
See my posting for an odd case.
ORACLE could tell the difference but .Net could not.
--
Joe Fallon



Paul Clement said:
¤
¤ ¤ > On Thu, 6 May 2004 14:56:07 -0700, Andrew
¤ >
¤ > ¤ I am trying to connect to Oracle 9i Database from Windows Service. This
¤ is the connection string :
¤ > ¤ User ID = ...;Password = ...;Data Source = ...
¤ > ¤
¤ > ¤ And I am getting an error:
¤ > ¤
¤ > ¤ "ORA-12154: TNS:could not resolve service name\n"
¤ > ¤
¤ > ¤ I tried changing Windows user name under which the service is running,
¤ doesn't help. Also when I run the same code from Windows Forms application
¤ everything works OK. I can connect to this server using SQL+. I am using
¤ .NET Framework 1.1
¤ > ¤ Please help.
¤ >
¤ > This would indicate to me that the account under which your service is
¤ running cannot see the
¤ > tnsnames.ora configuration file.
¤ >
¤
¤ Nope - it indicates that the instance identified by the SERVICE_NAME
¤ parameter in the tnsnames.ora file was not found by the listener server
¤ runnning the machine identified by the HOST parameter.
¤
¤ this from OTN:
¤
¤ ORA-12154: TNS:could not resolve service name
¤
¤ Cause: Oracle Net could not locate the net service name specified in the
¤ tnsnames.ora configuration file.
¤
¤ Action: Perform these steps:
¤
¤ 1.. Verify that a tnsnames.ora file exists.
¤ 2.. Verify that there are not multiple copies of the tnsnames.ora file.
¤ 3.. In the tnsnames.ora file, verify that the net service name specified
¤ in your connect string is mapped to a connect descriptor.
¤ 4.. Verify that there are no duplicate copies of the sqlnet.ora file.
¤ 5.. If you are using domain names, verify that your sqlnet.ora file
¤ contains a NAMES.DEFAULT_DOMAIN parameter. If this parameter does not exist,
¤ you must specify the domain name in your connect string.
¤ 6.. If you are not using domain names, and this parameter exists, delete
¤ it or disable it by commenting it out.
¤ 7.. If you are connecting from a login dialog box, verify that you are not
¤ placing an "@" symbol before your connect net service name.
¤ 8.. Activate client tracing and repeat the operation.
¤
¤ Cause: Oracle Net could not locate the database service name or net service
¤ name specified in the directory server.
¤

Since he can access Oracle via SQL Plus I don't believe it is a
tnsnames.ora configuration issue.
 
P

Paul Clement

¤ Paul,
¤ See my posting for an odd case.
¤ ORACLE could tell the difference but .Net could not.

Hi Joe,

Yes, I've heard of this issue before as well.

Thanks.


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top