Implementation of Oracle database operation with ASP

Source: Internet
Author: User
Tags count error code error handling functions connect ole oracle database support microsoft
oracle| Data | Database ASP (Active Server Pages) is one of Microsoft's tools for developing Internet applications, and the interface between ASP and database is generally implemented through ADO (Activex Data Object), like the computer world As described in the "ASP for SQL Server database Operations" article of March 20, 2000, ADO can fully support Microsoft SQL Server, but there are some difficulties with Oracle database services that are broader and more complex to use, If you want to make some simple query functions, ADO is enough, if you want to better play the features of Oracle database, such as STORED procedure,stored function, you should take advantage of ASP access Oracle Another powerful tool for database services---Oracle Object Server in Oracle object for OLE. This article explains how to use the control provided by Oracle Object Server in ASP to access the Oracle database, and discusses how to maintain the integrity constraint of network database.

----Oracle Object for OLE is a very needed product of Oracle company for client Access databases, which is based on Windows 95/98/NT for all OLE-compatible application and programming languages, such as ASP , Visual Basic excess97 and so on, Oracle object for OLE contains the Oracle Objects server (the Oracle Database Object Server), Orcle Data Control ) with three products such as the Oracle Object class library (the Oracle Objects for OLE C + + class library).

----compared to ADO, Oracle Object servers are products dedicated to the development of Oracle database applications, which have the following advantages:

----(1) The connection to the database server is running efficiently. Because ADO is connected to the database server through ODBC, the Oracle Object Server connects to the database server through Oracle Sql*net

----(2) can better play the unique functions of Oracle database. such as STORED procedure,stored FUNCTION, package, or multiple Cursor.

----This example is a directory of inquiries, entry of the small program, users can use the browser to query the address list, you can also input their own information for others to query.

The structure of the----Address Book table is as follows:

Name Null? Type
------------------------------- -------- ----
NAME not NULL CHAR (8)
Address CHAR (20)
PHONE CHAR (20)
EMAIL VARCHAR2 (30)

----First: Configure the Environment:
----Install the following software on the Web server and configure it:

----(1) Basic Web server (Web server) and ASP software

----(2) Oracle Object for ole2.x

----(3) sql*net client or Oracle NET8 client 8, after installation, use Sql*net Easy configuration to establish the database alias, the alias used to connect the ASP to the database.

----two. function realization

----(1) query: Use ASP to take the database Address Book list (TSB1) data, display the data on the screen. The key of the query is to determine whether the connection to the database is successful, the Oracle Object Server itself has error control mechanism to report the errors of the database connection, the specific procedures are as follows:


< HTML >
< tile > Query program </title >

< BODY >

<%

On Error Resume Next

' Connect to the database

Set Orasession=createobject
("Oracleinprocserver.xorasession")
Set Oradatabase=orasession.
Dbopendatabase ("axp03", "Scott/tiger", 0)

' Error handling

If Err.Number >0 Then

Response.Write "< h4 >asp error control </H4 >"

Response.Write "ASP Error Source:" &err.source & "< br >"

Response.Write "ASP Error code:" &err.number& "< br >"
Response.Write "ASP Error Description:" &err.description& "< br >"
Err.Clear
Response.Write "< h4 >oracle OLE error control </H4 >"
Response.Write ORACLE Error Code:
"&OraSession.LastServerErr&" < br > "

Response.Write ORACLE Error Description:
"&OraSession.LastServerErrText&" < br > "
Else

' Query

Sql= "SELECT * from TSB1"

Set Oradynaset=oradatabase.dbcreatedynaset (sql,0)

Response.Write "< h3 >result


Response.Write "< table border=5 >< tr >"

For I=0 to Oradynaset.fields.count-1

Response.Write "< td >"

Response.Write Oradynaset.fields (i). Name & ""
Response.Write "</td >"
Next
Response.Write "</tr >"
Do Until oradynaset.eof
Response.Write "< tr >"
For I=0 to Oradynaset.fields.count-1
Response.Write "< td >"
Response.Write Oradynaset.fields (i). Value
Response.Write "</td >"
Next
Response.Write "</tr >"
Oradynaset.dbmovenext
Loop
Response.Write "</table &



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.