|
FAQ #1: I cannot connect to
Oracle via ASP....
contributed by Bret H.
Grade bgrade@aris.com
MCSE, MCP+Internet Senior Consultant,
ARIS Corporation Inquire at http://www.aris.com
What do I need for connectivity for Oracle from ASP:
This question is a very valid question for most people beginning and experienced with
Oracle from within ASP. Because of the variety of things that are needed, there can be
many answers to this question. Here are the basics:
- SQL*Net needs to be loaded on the machine where IIS resides.
- A "System" DSN (Data Source Name) should be configured on the machine where
IIS resides. Or you may use a "DSNless" connection. A connection of this type
still requires you have the correct ODBC driver. See below.
- Your DSN connection consists of an ODBC driver. Here are your most utilized choices:
- Microsoft ODBC Driver for Oracle 2.00.00.6325 (Microsoft supplied driver)
- Microsoft ODBC for Oracle 2.573.3513.00 (Microsoft supplied driver)
- Oracle ODBC Driver 7.x or 8.x (Oracle supplied driver)
Most people prefer to use the Microsoft ODBC Driver for Oracle 2.0 for the reason that
is seems to be more stable than the 2.5 driver from MS.
The Oracle ODBC Driver has a variety of incompatibility problems with ASP and it is not
recommended to use this driver.
Make sure youve tested the DSN before you implement. This will prevent you from
having to deal with connectivity problems at this level while developing.
- The TNSNAMES.ORA file needs to have been configured on the machine where IIS resides.
This file is located in you ORANT\NETWORK (or NET80)\ADMIN\ directory. An Example
configuration is provided below:
orcl.world =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS =
(COMMUNITY = tcp.world)
(PROTOCOL = TCP)
(Host = THE IP ADDRESS OF YOUR HOST OR DNS NAME)
(Port = 1521)
)
(ADDRESS =
(COMMUNITY = tcp.world)
(PROTOCOL = TCP)
(Host = THE IP ADDRESS OF YOUR HOST OR DNS NAME)
(Port = 1526)
)
)
(CONNECT_DATA = (SID = ORCL)
)
)
Some things to note are the HOST, CONNECT_DATA, and PORT parameters.
- The host is the IP address or DNS name of the machine where the Oracle instance
(database) you are trying to connect to resides.
- The CONNECT_DATA string is made up of the Oracle SID. The SID is the name of the Oracle
Instance.
- The PORT parameter is defaulted to 1521 and 1526. These are the default installations
where the listener listens for requests from the machine where Oracle is installed.
What does a connection string to Oracle look like?
Set AUM = Server.CreateObject("ADODB.Connection")
AUM.Open Connect_String(DSN), USERNAME, PASSWORD
How do you configure the Oracle ODBC Driver?
To configure the ODBC driver, you will first need to :
- open the "ODBC Data Sources" icon in the control panel applet.
- Once opened, go to the "System DSN" tab and choose add. Select an ODBC driver
(See "WHAT DO I NEED FOR CONNECTIVITY FOR ORACLE FROM ASP").
- Once selected, you will see the following screen minus everything below connect string.
If you want the advanced configuration as shown below select options.

* The above example is utilizing the "Microsoft ODBC Driver for
Oracle 2.00.00.6325" driver.
Im getting an error with my SQL statement and I dont know why!
This problem seems to come up quite often. Rest assured, it is not just common to
Oracle. Most of the time this problem is because the developer has not tested the SQL
statement in question via a SQL tool (i.e. SQL Plus for Oracle or ISQL in SQL Server).
Some of the steps you should take when debugging are:
- ALWAYS run your command through SQL*PLUS if your statement fails. This way you eliminate
the fact that it could be a syntax problem with Oracle.
- If you have successfully tested the statement against the database outside of ASP, make
sure your statement is syntactically correct with ADO.
- Make sure all concatenated statements have the correct spaces in them.
sqlChk = "SELECT COUNT(NAME)"
sqlChk = sqlChk & " FROM MYAPP_USERS"
sqlChk = sqlChk & " WHERE NAME = UPPER('" &
Request.Form("txtUserID") & "')"
* Note: Although eliminating the number of lines for interpretation can optimize your
code, some prefer readability to the slight performance increase.
If you were to look closely, you would notice that the second and third line have a
space between the start of the clause and the ". Another method to insure proper
spaces between concatenated statements would be to put the space at the end of each line.
- Response.Write your sql statement to the screen.
- Make sure that you DO NOT have spaces in your table names.
I keep getting a TNS error while trying to connect.
Check the following:
- Insure that you can connect via SQL*PLUS. This will confirm that your TNSNAMES.ORA file
is configured properly. If not, check the following:
- Verify the instance is running (i.e. Oracle is up).
- Make sure you have a TNSNAMES.ORA entry.
- Check to see that the "TNS listener" service is running on the machine
where Oracle resides.
- Check to make sure that you have the correct ODBC driver.
- If you can connect via SQL*PLUS, check the following:
- Check to make sure that you have the correct ODBC driver.
 |  |  |
 |
There are many worthy charities!!. But perhaps help starving children in Africa or South America AND help Charles too.
a $5 tip buys him lunch at McDonalds,
a $20 tip buys his kid Hitoshi a new computer game,
a $39 tip buys his daughter Michiko a few nice outfits.
See our donor list.
|  |
 |  |  |
|
|
|
|