A deadlock occurs when ASP is used to operate the ACCESS database. LDB Solution

Source: Internet
Author: User

So I logged on to the Management Panel of the host and restarted the website service. The LDB file disappears and the website opened normally. However, after several hours, the website again encountered the above situation, this situation lasted for a while, and the website was later blocked by the virtual host supplier. The feedback to me was that my website occupied a lot of CPU resources during operation, so it was temporarily blocked, let me Program Or optimize the database.
I searched for this information on Baidu and found a lot of results. In conclusion, it is mainly because after the database is accessed, the record set is not released in time and the database connection is disconnected, the following describes how to operate an Access database:
1. database connection method: conn. asp
<%
Dim Conn
Dim connstr
Dim DB
DB = "database/data. mdb"
Set conn = server. Createobject ("ADODB. Connection ")
Connstr = "provider = Microsoft. Jet. oledb.4.0; Data Source =" & server. mappath ("" & dB &"")
Conn. Open connstr
If err then
Err. Clear
Set conn = nothing
Response. write "the server is being maintained. Please try again later. "
Response. End
End if
Sub closeconn ()
'Here are the statements for disconnecting the database.
Conn. Close
Set conn = nothing
End sub
%>
2. Disable the release record set.
Rs. Close
Set rs = nothing
3. Disconnect the database
Conn. Close
Set conn = nothing
Combined with the above three content, the following standard method for operating the ACCESS database test. asp is obtained.
<! -- # Include file = "conn. asp" -->
<%
SQL = "select * from Table order by ID"
Set rs = server. Createobject ("ADODB. recordset ")
Rs. Open SQL, Conn, 1, 1
If not Rs. EOF then
Tel = RS ("tel ")
Fax = RS ("fax ")
End if
'Close and release the record set statement below
Rs. Close
Set rs = nothing
'Call to disconnect the database from the subfunction
Call closeconn ()
%>
According to this standard, I checked and leaked my website programs. Finally, my website had to be accessed normally and there was no database deadlock.

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.