Groups | Blog | Home
all groups > dotnet general > november 2005 >

dotnet general : Oracle connection string problem



Bala Nagarajan
11/14/2005 6:18:42 PM
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

v-kevy NO[at]SPAM online.microsoft.com
11/15/2005 7:49:18 AM
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."
Bala Nagarajan
11/21/2005 12:13:09 PM
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

[quoted text, click to view]

v-kevy NO[at]SPAM online.microsoft.com
11/22/2005 11:31:02 AM
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."
Bala Nagarajan
12/12/2005 1:01:04 PM
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

[quoted text, click to view]

Ralph
12/12/2005 10:19:20 PM

[quoted text, click to view]

Yes.

v-kevy NO[at]SPAM online.microsoft.com
12/13/2005 6:18:19 AM
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."
AddThis Social Bookmark Button