Oracle DSN example?

I?ve just been tasked with building an application that extracts data from an Oracle database and then populates several fields on an ASP page. I do not need to make any updates to the Oracle database. I?ve been able to do this in the past using an Access database, but now I need to get the information from Oracle and I will have to use a DSN because the Oracle database is on a different server. I will also need to use a username and password to access the Oracle database. I have no experience with using a DSN, so I?m at a total loss as how to accomplish this task.

Can someone show me an example of how to do this?

Thanks!
RougieAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hongjunCommented:
Syntax of connection strings
http://www.able-consulting.com/ADO_Conn.htm

hongjun
0
nigelroweCommented:
What driver will you use ODBC or OLEDB? If ODBC, I strongly advise that you get an ODBC driver from Oracle, the MS version is a bit buggy.

Then its something like...

DSN..
Conn.Open "DSN=wipost32_ora" ' note, the id and pass are usually defined in the dsn

OLEDB..
Conn.Open Provider=OraOLEDB.Oracle.1;Persist Security Info=False;User ID=nigel;Data Source=sant
0
PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

AvocadoIsleCommented:
Here's the code we're using with an oracle database:

Dim strConn, strRecSet, strSQLQuery
Set strConn = Server.CreateObject("ADODB.Connection")
strConn.Open "DSN=YourDSNName;UID=YourOracleUserName;PWD=YourOraclePassword"
Set strRecSet = Server.CreateObject("ADODB.Recordset")
strSQLQuery = "Your Query Here"
strRecSet.Open strSQLQuery, strConn

And you need to set up the DSN properly on your NT server running the web application.  At this point I'm a little unclear but you need to add a system DSN using Oracle drivers (there is a Microsoft ODBC driver for Oracle included with the system).  Go to control panel/ODBC data sources/system DSN/Add and select the proper Oracle driver and supply the DSN name & description.

The username and password should be the one supplied by your Oracle DBA.

HTH
0
nigelroweCommented:
sorry, that should be

OLEDB..
Conn.Open "Provider=OraOLEDB.Oracle.1;Persist Security Info=False;User ID=nigel;Data Source=sant"

The latest Oracle ODBC drivers can be obtained from ...

http://otn.oracle.com/software/utilities/software_index.htm
0
jitgangulyCommented:
I am surprised none of you guys explaied about tnsnames.ora. Using Oracle db with a DSN connection is very different than SQLServer or access.
Now here are the steps

1. You should have Oracle client installed on your web server.
2. Look for a file called TNSNAMES.ORA. It should be in \orant\network\admin
3. You should have a TNS connection in tnsnames.ora. Generally the name ends with .ora. A typical example would be

mydb.world =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = ls0167.abc.xxx.com)(PORT = 10007))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = abc.def.COM)
    )
  )

4. Now go to Control panel, odbc32. Click on System DSN tab, click ADD and choose Microsoft ODBC for oracle. You should use Microsoft ODBC for oracle as Oracle ODBC is full of bugs. If you can not see Microsoft ODBC, download MDAC 2.5 (yes 2.5 not 2.6) from MS site (www.microsoft.com/data). The version for MS odbc for oracle shoudl be 2.573xx. I had problems using MDAC 2.6 with oracle driver as well Oracle ODBC driver. When you chosse MS ODBC fro oracle and click Finish, system will prompt you with Data Source name, specify any name (thats your dsn name), username should be equal to Oracle user name and password is oracle passowrd. Now in server filed specify the tns name from tnsnames.ora. THE SERVER NAME MUST BE EQUAL TO THE TNSNAME.

5. You are all set now to use this DSN in your ASP pages.
A typical example would be

Set Application("SecConn") = Server.CreateObject("ADODB.Connection")
Application("Oracle_DSN") = "mydsn"
Application("Oracle_Username") = "myuserid"
Application("Oracle_Password") = "mypassword"
Application("SecConn").Open Application("Oracle_DSN"), Application("Oracle_Username"), Application("Oracle_Password")


Remember the date manipulations in oracle is different than Access. You don't use # sign to compare dates. It has some excellent function like TO_DATE, TO_CHAR etc.

Let me know
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nigelroweCommented:
Well, I was assuming that this would have been carried out by the DB administrator if they changed the DB from Access to Oracle
0
jitgangulyCommented:
No, why ? Is creating a dsn DBA job ? I do it myself. I don't know ...
0
nigelroweCommented:
No it's no a DBA job, but you have to have either ODBC or OLEDB installed. If you don't, you'll have to ask DBA what type of connection to use.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.