Using Oracle Object for OLE to access Oracle 8 in ASP

Source: Internet
Author: User
Tags count microsoft sql server odbc ole query access database oracle database support microsoft
object|oracle| Access ASP (Active Server Pages) is one of Microsoft's tools for developing Internet applications, a similar HTML (hypertext
Markup Language Hypertext Markup Language), script and CGI (Common Gateway Interface Universal Gateways Interface), but its operational efficiency is
Higher than CGI, programming is easier and more flexible than HTML, and program security and confidentiality are much better than script. Therefore, ASP is the current Web development technology
The most easy to learn, the most flexible development tools.
ASP's built-in ADO component is the Internet Database access solution developed by Microsoft Company, and it is also an important contributor to ASP Access database, ADO through ODBC access number
According to the library, ADO can theoretically access a variety of databases supported by ODBC, such as Microsoft SQL Server,access,foxpro,oracle,dbase,
However, in practice, we found that ADO can fully support Microsoft SQL Server and acess, but it is difficult for Oracle, the author in the practice of Li
Using ADO to access Oracle8, it is found that ADO cannot access Oracle8 numeric fields and finds that ADO access Oracle8 is extremely slow.
In order to solve the speed of using ASP to access Oracle8 and other technical problems, the author tries to use Oracle Object for OLE to access Oracle8, the result is completely
Got the result I expected.
Oracle Object for OLE is an important product that Oracle has developed for client access to the database, and it is based on windows95/98/nt
All OLE-compliant applications access the Oracle database. It is an OLE server without a user interface that contains Oracle Objects server that is an ASP
One of the key contributors to accessing Oracle databases.
To access the ORACLE8 database through Oracle Objects server, in addition to the basic Web server and ASP software, you must also determine that the Web server has been
Oracle Object for OLE software is installed with the required software: Network Protocol Adapter, Oracle object for OLE2. X
Sql*net client2.x or Oracle Net8 client8.x, Sql*plus, and Oracle8 ODBC Driver. After you have determined that the Web server has the above software installed,
You must also use the Sql*net client2.x or Oracle NET8 client8.x to test database connectivity and set the database alias.
Oracle Objects Server provides oraclient, Orasession, Oraconnection, Oradatabase, Oradynaset, orasqlstmt,
Orafield, Oraparameter, oraparameter array, etc. nine objects for developers to use. Its function and function are described as follows:
1. Oraclient objects
The Oraclient object is used to define the scope of the server-side (client or workstation), and Oraclient records all Orasession objects on this server side.
Oraclient are automatically established by the system as needed.
2. Orasession objects
The Orasession object is used to manage objects such as oraconnection, Oradatabase, and Oradynaset in a program, and it is established as follows:
Set orasession=create ("Oracleinprocserver.xorasession")
3. Oraconnection objects
The Oraconnection object represents a connection to a Oradatabase object, and when a Oradatabase object needs to be created, the system automatically generates a oraconnection
Object. Conversely, when disconnected from the database, the Oraconnection object is automatically freed.
4. Oradatabase objects
The Oradatabase object represents a virtual login to the database server, and its logon method is as follows:
Set Oradadabase=orasession.dbopendatabase_
("Database Alias", "User name/password", 0)
5. Oradynaset objects
The Oradynaset object stores the data of the Select command in the client's buffer, lets the user browse or update, and finally writes the result
To return to the server, the method is as follows:
Setoradynaset=oradatabase.dbcreatedynaset ("SQL statement", 0)
6. ORASQLSTMT objects
The Orasqlstmt object is typically used to run SQL commands, or to call stored procedures, using the following:
Set orasqlstmt=oradatabase.createsql ("SQL statement", 0)
7. Orafield objects
A Orafield object represents a field or data item in a Oradynaset object that sets or obtains a field in a Oradynaset object by using the Value property
Value.
8. Oraparameter objects
The Oraparameter object represents a variable that is attached to an SQL command or PL/SQL program block.
9. Oraparameter Array Object
The Oraparameter array object is an array type of Oraparameter object, and the Oraparameter array object can indirectly pass through the Oradatabase object's
Oraparameter data collection to add, access, or delete a variable.

Here is a concrete example of how to use Oracle Object for OLE to access Oracle 8 in ASP.
The author has written a program that uses Oracle Object for OLE2.3 in ASP to query Oracle 8.0.5 database and to display paging. Because
The property of the Orasession object does not control the paging property, so the author has compiled a paging control program.
The following total of two ASP files (query.asp and query1.asp), query.asp files first get the contents of the database table, and then calculate the page number of pages, if the number of pages exceed
Over a page, then to query1.asp processing, the program code as follows
' Query.asp
<%
' Connect to the database
Set Orasession=createobject ("Oracleinprocserver.xorasession")
Set Oradatabase=orasession.dbopendatabase ("Orant", "Scotter/tiger", 0)
' Set query criteria
Sql= "SELECT * from CQ_HJWJ"
Set session (Oradynaset) =oradatabase.dbcreatedynaset (sql,0)
' Set page length
Pagesize=15
If session (Oradynaset). Recordcount=0 Then
Response.Write "No qualifying data"
Else
Response.Write "' Count pages
Pages=int (Session (Oradynaset). Recordcount/pagesize)
If Pages*pagesize=session (oradynaset). RecordCount Then
Pages=int (Session (Oradynaset). Recordcount/pagesize)
Else
Pages=int (Session (Oradynaset). Recordcount/pagesize) +1
End If
If Request ("page") = "" Then
Page=1
Else
PAGE=CSTR (Request ("page")
End If
Response.Write "&pages&" page, at present the "&page&" page
Response.Write "<table border=5><tr>"
For i=0 to session (Oradynaset). fields.count-1
Response.Write "<td>"
Response.Write Session (Oradynaset). Fields (i). Name
Response.Write "</td>"
Next
Response.Write "</tr>"
startrow= (page-1) *pagesize+1
Endrow=page*pagesize
Oradynaset.moveto StartRow
For J=startrow to Endrow
Response.Write "<tr>"
For i=0 to session (Oradynaset). fields.count-1
Response.Write "<td>"
Response.Write Session (Oradynaset). Fields (i). Value
Response.Write "</td>"
Next
Response.Write "</tr>"
Session (Oradynaset). Dbmovenext
If session (Oradynaset). EOF then Exit for
Next
Response.Write "</table>"
End If
If Pag



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.