Connect via ASP with Access database (with source code) (1)

Source: Internet
Author: User
Tags odbc reset access database

Objective:

How to establish a connection with the database through ASP is a very realistic problem, I try to write very detailed. I believe you have been able to write similar simpler and more practical programs by reading this article.

(i) Selection of databases:

There are a number of databases you can choose from, SQL SERVER, ACCESS (*.mdb), EXCEL (*.xls), FOXPRO (*.dbf), and even plain text files (*.txt) can achieve the ability to store data. So what is the best way to choose a database? Where SQL Server is server-level enough to handle tens of thousands of visits per day. It is recommended that you use ACCESS97 for non server-level databases. because: (1) As long as the installation of PWS or IIS4 must have access ODBC drive, that your system will certainly support Access database access. (2) Access supports a very complete range of SQL instructions. (3) ACCESS ODBC drivers are highly efficient. Although it is not a server-level database, database support for small and medium enterprise intranets is more than sufficient. (4) ACCESS97 in OFFICE97, very convenient to get and use.

This article introduces the Web-based database access method based on the Access database.

(b) Example: We set up a "customer" database, we need to keep the following customer information: Customer name, contact person's name, city, telephone number.

(1) First set up Access database Customer.mdb (useful in the future). Establish the following fields: Customer name, contact person name, city, telephone number, customer number, time. Save the table as "customer" (,===>) for future use. Note: More than 2 (customer number, time) were made when the field was established because they were used in future sorting. It is advisable to add these 2 items to the database in the future, it will not be useless. Also, when you save the table, Access asks if you want to create a live keyword, and we don't need it so we don't have to build it. Also: the Time field's "Default value" is set to "Now", that is, to the time of the system. At the same time, set the index entry to have (Allow duplicates), meaning: The web is very likely to access the data at the same time, so allow duplication, index set to "have" can speed up the sorting speed. ===>, look at the picture.

(2) Establish submitting form add.htm:

The source code is as follows:

<title> Add database Records </title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<body bgcolor= "#FFFFFF" >
<p align= "center" ><font size= "5" > Add database Records </font></p>
<form method= "POST" action= "adddatabase.asp" >
<div align= "center" >
<table width= "46%" border= "0" >
<tr>
&LT;TD width= "28%" >
<div align= "Right" > Company Name: </div>
</td>
&LT;TD width= "72%" >
<input type= "text" name= "CompanyName" >
</td>
</tr>
<tr>
&LT;TD width= "28%" >
<div align= "Right" > Contact person Name: </div>
</td>
&LT;TD width= "72%" >
<input type= "text" name= "CName" >
</td>
</tr>
<tr>
&LT;TD width= "28%" >
<div align= "Right" > City: </div>
</td>
&LT;TD width= "72%" >
<input type= "text" name= "City" >
</td>
</tr>
<tr>
&LT;TD width= "28%" >
<div align= "Right" > Phone number:</div>
</td>
&LT;TD width= "72%" >
<input type= "text" name= "Tel" >
</td>
</tr>
<tr>
&LT;TD width= "28%" >
<div align= "right" > </div>
</td>
&LT;TD width= "72%" >
<input type= "Submit" name= "submit" value= "Submit" >
<input type= "reset" name= "reset" value= "reset" >
</td>
</tr>
</table>
</div>
</form>
</body>

This is no different from normal HTML, and the key part is already marked with yellow. The submission method uses post, the Post processing procedure is adddatabase.asp (the next step focuses on it). Another is to give each item a name (name, useful later).



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.