database connection.

W

wei

i tested database connection to oracle. the code worked on windows
application but didn't work on web application. the code is as following:
OleDbDataAdapter DataAdapter = new OleDbDataAdapter(commandString,
connectionString);

DataSet dataSet = new DataSet( );

// fill the data set object

DataAdapter.Fill(dataSet,dataSetName);

// Get the one table from the DataSet

DataTable dataTable = dataSet.Tables[0];


return dataTable;

codes in two application are exactly same. when run web application, it
stopped at DataAdapter.Fill(dataSet,dataSetName) and gave an exception
message of:

ORA-12154: TNS:could not resolve service name
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: ORA-12154: TNS:could
not resolve service name

did i miss something?

thank you for any help.
 
C

Craig Deelsnyder

wei said:
ORA-12154: TNS:could not resolve service name
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: ORA-12154: TNS:could
not resolve service name

looks like something in your connectString is not correct. It should
not have to be different for web vs win. I'd check to make sure your
web app is setup correctly for database access. Also check the tns
settings for your oracle connection on that box.

Actually, maybe it's because of permissions, you can't read the file
where the tns values are stored. If this is a dev box, try temporarily
changing your user setup in machine.config to SYSTEM instead of machine
(it's in the processModel node/section). Then re-run this. See if it
works. (and then of course, as a good developer, change machine.config
back :) )

If it fails (which I would hope), then you know it's something with
permissions for the aspnet account accessing some Oracle settings/files.
Maybe have to give the aspnet user access to that directory. I
haven't worked with Oracle in awhile, so I'm drawing from vague memories...
 
W

wei

Thanks Craig. i think you are right.the connectString is not set properly.
if i down the ip address, how do i set it?
string connectionString = "Provider=MSDAORA.1;Data source=server;User
ID=username;Password=password";

this is my current setting. i try to replace server with ip+port, it didn't
work either. how do i set it? thanks.
 
C

Craig Deelsnyder

wei said:
Thanks Craig. i think you are right.the connectString is not set properly.
if i down the ip address, how do i set it?
string connectionString = "Provider=MSDAORA.1;Data source=server;User
ID=username;Password=password";

this is my current setting. i try to replace server with ip+port, it didn't
work either. how do i set it? thanks.



wei wrote:


Actually, maybe it's because of permissions, you can't read the file
where the tns values are stored. If this is a dev box, try temporarily
changing your user setup in machine.config to SYSTEM instead of machine
(it's in the processModel node/section). Then re-run this. See if it
works. (and then of course, as a good developer, change machine.config
back :) )

If it fails (which I would hope), then you know it's something with
permissions for the aspnet account accessing some Oracle settings/files.
Maybe have to give the aspnet user access to that directory. I
haven't worked with Oracle in awhile, so I'm drawing from vague
memories...

Here's a site that shows connection strings for different DBs,
providers, etc.:

http://www.connectionstrings.com/

Did you try the permissions check, that's becoming more and more likely
in my mind? Try either changing your user id that ASP.NET runs under to
SYSTEM, or give aspnet access to the folder with the tns entries.....I
don't remember where Oracle stores those on the server.
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top