Recommended: A brief analysis of the Debug class in ASP--VBScript I don't know if friends who write code in ASP have the same feeling as me. The most troublesome thing in ASP is that it is inconvenient to debug programs. I think many friends may use this method "response.write" and then output relevant statements to see if it is.
ASP (Active Server Pages) is one of the tools proposed by Microsoft to develop Internet applications. The connection between ASP and databases is generally implemented through ADO (Activex Data Object). Just as the article "Operating SQL Server Database with ASP" on "Computer World" on March 20, 2000, ADO can fully support Microsoft SQL Server, but it has some difficulties in ORACLE database services with more extensive applications and more complex mechanisms. If you want to do some simple query functions, ADO is enough. If you want to better play the unique functions of ORACLE databases, such as STORED PROCEDURE, STORED FUNCTION, etc., you must use ASP to access ORACLE. Another powerful tool for database services - the ORACLE Object Server in Oracle Object for OLE. This article uses an example to illustrate how to use the controls provided by the ORACLE object server in ASP to implement access to the ORACLE database, and discusses some discussion on how to maintain the integrity constraints of the network database.
Oracle Object for OLE is a very needed product developed by ORACLE for client access databases. It uses Windows 95/98/NT as the basis for all OLE-compatible applications and program languages to access ORACLE databases, such as ASP, Visual Basic Excess97, etc. Oracle Object for OLE includes three products, including the ORACLE object server, the Oracle Data Control, and the ORACLE object class library.
Compared with ADO, ORACLE object server is a product dedicated to ORACLE database application development, and it has the following advantages:
(1) The connection to the database server is efficient. Because ADO connects to the database server through ODBC, and the ORACLE object server connects to the database server through ORACLE SQL*NET
(2) Better play the unique functions of the ORACLE database. Such as STORED PROCEDURE, STORED FUNCTION, PACKAGE or Multiple Cursor. The structure of the address book list is as follows:
| The following is the quoted content: 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 and other software
(2) Oracle Object for OLE2.x
(3) SQL*Net Client or Oracle Net8 Client 8, after installation, use Sql*Net Easy Configuration to create a database alias (Database Alias) to connect to the database.
two. Functional implementation
(1) Query: Use ASP to get the data of the database address book table (TSB1) and display the data on the screen. The key to query is to determine whether the connection to the database is successful or not. The ORACLE object server itself has an error control mechanism to report errors in database connection. The specific procedures are as follows:
| The following is the quoted content: < HTML > < tile > Query Programs</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.writeasp Error source: &err.source &< br > response.writeasp Error code: &err.number&< br > response.writeasp Error description: &err.description&< br > err.clear response.write< h4 >ORACLE OLE Error control< /h4 > response.writeORACLE Error code: &OraSession.LastServerErr&< br > response.writeORACLE Error description: &OraSession.LastServerErrText&< br > else Query sql=select * from tsb1 set oradynaset=oradatabase.dbcreatedynaset(sql, 0) response.write< h3 >result< /h3 > 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 > |
Close the database
| The following is the quoted content: oradatabase.close set orasession=nothing end if % > < /body > < /html > |
The following is the query result diagram of the program:
Share: How to interpret the Server object error of ASP website Symptoms: The following error occurred when accessing the asp web page: Server object error ''ASP 0178: 80070005''Server.CreateObject Access Error/_fpclass/fpdbrgn1.inc, line 99The call to Server.C
2 pages in total Previous page 12 Next page