ASP server Component Programming experience

Source: Internet
Author: User
Tags empty reset valid email address web database
Programming | server | experience writer; knife
One of the great advantages of using ASP programming is that you can use a large number of server components (ActiveX server components). These components provide such as advertisement wheel display
(Ad rotator), browser-compatible (Browser capabilities), database access, file hyperlinks (Content
Linking), file access (Files access), and so on. With server components, you can efficiently accomplish a variety of complex works in a very simple way

Generally, the components of an ASP are typically created using the Server.CreateObject method. For example, creating an Ad Rotator component is available:


Set ad = Server.createobjet ("MSWC. AdRotator ")


The ActiveX Data Object (ADO) component plays an extremely important role in the various components of the ASP. It is a Web page design developer who can provide
Fast access to the Internet database, and on the user side to achieve real-time online update display of web database technology; ADO is almost compatible with a variety of database systems, while
And across a variety of different programming language development environment.

For example, we provide a variety of hardware upgrades to our customer base on the Web, while at the same time we want to be able to record our customers ' relevant information. In
Previously, this kind of web interoperability was typically done with CGI, not only difficult to write and maintain, but also a huge drain on the processor. Now, we use the ASP's
ADO components, you can be in a short two hours before the easy completion of the three days to complete the development work, and do not have to spend too much time and effort
Put it on the maintenance.

First of all, we need to write a form page for the user to fill in the information, or we can also put this page and the following ASP processing program in the same file
, only the object that we need to mark the action in the <form> code is this program (or nothing at all).

Assuming that our program name is download.html, the following is the original code:


' How to declare a submission method and how to deliver it

<form method= "POST" action= "download.asp" >

<font face=arial>

<table border= "0" align=center>


<td><font color= "Black" size= "2" ><b>Name:</b></font></td>

<td><input type= "text" size= "a" name= "NAME" ></td>



<td><font color= "Black" size= "2" ><b>Telephone:</b></font></td>

<td><input type= "text" size= "name=" Telephone "></td>


<td><font color= "Black" size= "2" ><b>E-mail:</b></font></td>

<td><input type= "text" size= "" name= "email" ></td>



<td><font color= "Black" size= "2" ><b>Address:</b></font></td>

<td><input type= "text" size= "a" name= "address" ></td>




<table align=center><tr>

<td><input type= "Submit" value= "Submit" ></td>

&LT;TD width=30></td>

<td><input type= "reset" value= "reset" ></td>





Then we started writing the data processing program download.asp.

<script Language=vbscript runat=server>

' Set buffer properties


Dim Name

Determine if the field is empty

If Len (Request.Form ("name")) =0 Then

Name= "Not entered"


When not empty, use the response object to get the server to get the contents of the ' Name ' field in the table

Name=request.form ("name")

End If

Dim Telephone

If Len (Request.Form ("Telephone")) =0 Then

Telephone= "Not entered"


Telephone=request.form ("Telephone")

End If

Dim Address

If Len (Request.Form ("Address")) =0 Then

Address= "Not entered"


Address=request.form ("Address")

End If

Since we will send the download software to the user by email, we must ask the customer to provide a valid email address.

Dim Email

Email=request.form ("email")

' Do you have a special character ' @ ' in the ' Email ' information that the customer fills out?

If InStr (email, "@") =0 Then

' If no, lead the customer to the ' back.htm ' Prompt page.

Response.Redirect ("back.htm")


Establishing a Database connection channel

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

Open the database you want

objConn.Open ("Download")

Creating an Object interface

Set Objrst = Server.CreateObject ("ADODB. Recordset ")

Set objrst.activeconnection = objconn

When you set the database to update data, the locking mechanism is that the data does not lock other users ' actions when it is updated.

Objrst.locktype = 3

Database Source

Objrst.source = "Client"

Filter downloaded data types after data updates are controlled

Objrst.cursortype = adOpenKeyset

Transfer data obtained from a table to a database on a Web server


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: 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.