Oracle connection string problem

B

Bala Nagarajan

Hello,
I am using Oracle 9i in my application and facing a problem with the
connection string. In the datasource attribute of the connection string i
had to specify an entry in "tnsnames.ora" file for it to work correctly. If
i copy and paste the entry in the "tnsname.ora" file it complains the
connection string is too long. I want to avoid using the "tnsnames.ora" file
since it exposes the server (and needles to say the configuaration!) name
but at the same time specify a datasource in the connections string. How to
avoid "tnsnames.ora" file and specify a connection string?

Thanks

Bala
 
K

Kevin Yu [MSFT]

Hi Bala,

From the description, I think you need to connect to an Oracle 9i database
without using a tnsnames.ora file. Is there any misunderstanding here?

Using the tnsnames.ora file is the simplest way to access the Oracle
database. However, if you have concerns about disposing the data source,
you can try to hard code the connection string to your app.

If you're changing the connection string at runtime, you can also put the
connection string in the app.config file. Before put into the app.config
file, we can use some encryption mechanism to encrypt the whole connection
string. When getting the string, we decrypt it.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
B

Bala Nagarajan

Kevin,
I want to be able to connect to Oracle 9i database without having to
worry about "tnsnames.ora" file.My connection string looked something like
this

string connString = "DataSource =db.entry;UserID = usid;Password = pwd",

where "db.entry" is an entry from the tnsnames.ora fille which looks like
the following:

db.entry =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS =
(COMMUNITY = my.community)
(PROTOCOL = TCP)
(Host = myserver)
(Port = 9875)
)
)
(CONNECT_DATA = (SID = mydatasource)
)
)


Now the problem is the "tnsnames.ora" exposes the server name, database name
name and its port , which is a security risk according to me. So my
questions is how to get rid of "tnsmanes.ora" file and create a connection
string.

Kevin, i cannot place the entry in the app.config file and use it during
runtime because when i tried to copy the entry above to the "DataSource"
attribute of the connection string but .NET complains that the connection
string is too long. So how should i construct my connection string i for the
situation i discussed without using the "tnsnames.ora" file?

Thanks

Bala
 
K

Kevin Yu [MSFT]

Hi,

DataSource is server name or alias for the database you're connecting to.
According to the ora file, you can try to use mydatasource as the
DataSource.

DataSource=mydatasource

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
B

Bala Nagarajan

When i try to set the DataSource=mydatasource as you suggested i get the
following error.

An unhandled exception of type 'System.Data.OracleClient.OracleException'
occurred in system.data.oracleclient.dll

Additional information: ORA-12154: TNS:could not resolve service name

It seems to like the OracleClient always looks for "tnsnames.ora" file. Is
that right?
Does this mean that any .NET windows application using Oracle (running on
different server machine) should have oracle client installed?

Please explain.

Thanks
 
R

Ralph

Bala Nagarajan said:
When i try to set the DataSource=mydatasource as you suggested i get the
following error.

An unhandled exception of type 'System.Data.OracleClient.OracleException'
occurred in system.data.oracleclient.dll

Additional information: ORA-12154: TNS:could not resolve service name

It seems to like the OracleClient always looks for "tnsnames.ora" file. Is
that right?
Does this mean that any .NET windows application using Oracle (running on
different server machine) should have oracle client installed?

Please explain.

Thanks

Yes.
 
K

Kevin Yu [MSFT]

Hi Bala,

Yes, using OracleClient namespace must have Oracle client installed on that
machine. Since the provider is talking to Oracle client and Oracle client
then talks to the server.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 

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