ASP advanced article online Management update (i)

Source: Internet
Author: User

Author: Beach Boy
The previous section introduces the database structure of the article management system, after the establishment of the database, it is necessary to use ASP to establish a database-related procedures, including the connection to the database, display database content, update the database and other related programs, so this article will tell you how in the management system to connect with the database, and open the database. In the ASP program, generally will establish the database connection program to separate into a file, then directly with the <!--include file= "xxx.asp"--> to call on it, This eliminates the need to set up a database connection in the future page to enter the relevant statements each time to establish a connection, but also to change the name of the database more convenient. You think about it, if you write on each page to connect the database statement, then if you modify the database name is not to be changed every file, now use a separate file directly include, as long as the modification of a file can achieve the same effect, which is also a small ASP programming skills:
Here's how to set up a connection to a database:
Create a new ASP file conn.asp, the subsequent call to the database can be used <!--include file= "conn.asp", the following is conn.asp content and explanation:
<%
Dim conn
Dim connstr
The Execute subroutine
Call Conn_init ()
"Sub-program to connect to a database
Sub Conn_init ()
"To respond to a program interrupt caused by a run-time error, it can move the control to the statement immediately following the statement that generated the error, and you may not use this statement, and when an error occurs, the program stops and there is an error message to the user!"
On Error Resume Next
"Use the server. MapPath to specify the path to the database, where the path is a relative path
Connstr= "dbq=" +server.mappath ("Bookid.mdb") + ";D efaultdir=;D river={microsoft Access DRIVER (*.mdb)};"
"Connect the database with the Connection object
Set Conn=server.createobject ("ADODB. CONNECTION ")
"Open a connected database with open
Conn.Open ConnStr
End Sub
%>
In this way, a complete database connection and open file is done, the database and its connection are done, next should introduce how to add data to the database, of course, can not be directly added to the database, which lost the meaning of this program: the next section will introduce the article online add and save.
Reprint please indicate the source http://

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.