ASP optimization: Recognizing and optimizing connection objects

Source: Internet
Author: User

In this database connection. We used the session object, first of all, to establish a Conn connection object, and then connect to the database Data.mdb, get the connection handle, save it in session ("Conn") the sessions variable, before opening the recordset, from the session ( "Conn") to remove the handle from the session object. We can make different ASP pages share a connection object, reduce the cost of server memory, and we do not need to worry, when a customer because of the error operation caused the server can not be able to put the occupied session connection object, Because we know that each client's session object is a certain survival period, after this period, the server will automatically put it off.

Shanghai treatment of Impotence Hospital program: In the ASP database programming, Connection object is we can not leave an object, in the database to do any operation, such as update record, insert, delete, search, etc., all must rely on the connection object to complete. Visually speaking, the connection object is the pipeline that the program communicates with the database, all operations on the database must pass through it, so no matter how we connect the database, we always have to execute the following code.

Set conn = Server.CreateObject ("ADODB. Connection ")

Create an instance variable of an connection object, and then build a Recorderset object or command object to manipulate the database on its basis. Since the connection object is so important, how to optimize and manage the connection object is extremely important to the database program, which is related to the performance of the program.

Every time a customer performs a database operation, a connection object is needed, and each connection object consumes a portion of the server's resources, while the number of simultaneous connections to the database cannot be infinite. When filtering to provide a high-performance database Web program, we need to filter how to reduce the cost of the server. Generally speaking. Creating a Connection object in each ASP page creates a connection to the database in the server. The connection objects of different pages cannot be shared. So. Can we share a connection connection channel with different pages that the same user accesses?

We can think of our ASP six built object of the session object, he can for a specific user to save private data, if we save the connection object in the Session object, whether the different ASP pages will use the same connection channel it? Take a look at this procedure below.

$#@60;% Set conn = Server.CreateObject ("ADODB. Connection ") DBPath = Server.MapPath ("/") &"/news/data/data.mdb "Conn. Open "Driver={microsoft Access driver (*.mdb)};d bq=" & DBPath session ("conn") =conn Set rs = Server.CreateObject ("Adod B.recordset ") sql=" SELECT * from Data "cn=session (" conn ") Rs.Open sql,cn,3,2%$#@62;d width=" 100% ">

In this database connection. We used the session object, first of all, to establish a Conn connection object, and then connect to the database Data.mdb, get the connection handle, save it in session ("Conn") the sessions variable, before opening the recordset, from the session ( "Conn") to remove the handle from the session object. We can make different ASP pages share a connection object, reduce the cost of server memory, and we do not need to worry, when a customer because of the error operation caused the server can not be able to put the occupied session connection object, Because we know that each client's session object is a certain survival period, after this period, the server will automatically put it off.

The connection pool provided by ODBC3.0 is connection pooling. can also effectively improve the performance of the database operation. We know that in the numerous ASP pages generated by the connection object, always in the constant establishment of the connection, the release connection, the analysis and release of the connection.

Shanghai treatment Impotence Hospital How to effectively manage and use these abandoned connections can also greatly improve the operational efficiency in certain procedures. The ODBC3.0, in turn, provides the ability to intelligently redirect a newly created connection to a connection object that is about to be discarded and use it over and over again. In this way, you can save a bad server overhead.

ASP optimization: Recognizing and optimizing connection objects

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.