Small problem, big hidden dangers - the object release of theSP

xiaoxiao2021-03-06  73

Properly exposed ASP procedures, not very clear for the use of objects, some problems, have been corrected with the help of others, I want to write it as an advice to prevent themselves in the same mistake. If you have something wrong, I hope everyone will correct it.

For ASP programs, there are several basic built-in objects: Application objects, Request objects, response objects, Server objects, session objects, and most of the ASP operation code is a method of using these built-in objects.

In addition to the above built-in objects, we usually write ASP procedures (involving databases) need to use the following newly created objects: 1. Database connection objects generalize this object called Connection Creative Method Dim Proconnset Proconn = Server.createObject ("AdoDb.Connection") Use this Connection object to open an Access database proconn.open "driver = {Microsoft Access Driver (* .mdb)}; uid =; pwd =; dbq =" & Server.mAppath (" Db.mdb ")

2. Recordset object This object is mainly used to execute database queries in ASP code DIM RSSET RS = Server.CreateObject ("AdoDb.Recordset") RS.Open strsql, proconn, 1, 1'strsql is SQL The string of statements 'proconn is Connection object' 1, 1 is a cursor parameter.

The above two objects are often encountered, they must pay attention to the release of these objects after the use is.

The release method is as follows: proconn.close = nothing set = Nothing

The next thing to say is to reference the object of the homemade DLL, and please refer to how to encapsulate the ASP code for the DLL.

This object is used as follows: DIM CONDBSET CONDB = Server.createObject ("Condbdll.conn") 'Call CONDB's method CONDB.CONNECTDB () CONDB.DBPATH ()' connectionDB () and dbpath () are this package DLL Custom method

CreateObject ("condbdll.conn") is the engine name of this DLL, conn is a simple set condb = server.createObject ("condbdll.conn") in this project, makes Condb into a homemade Object.

It is such a simple object, but I forgot to release the other ASP source code file that invokes the ASP file that creates this object, causing a huge hidden danger in the future.

In this way, there is no release, after using the website of this ASP, the system will become slow, because the object is not released. They are all uncomfortable results. Hey………

转载请注明原文地址:https://www.9cbs.com/read-118728.html

New Post(0)