When you write a server-side application with ASP, you must rely on the ability of the ActiveX component to power the web application, such as: You need to connect the database, perform online operation on the database, etc., follow the article, after the article, this article Will then give you some other commonly used ASP ActiveX components.
There are still many friends in recent recently to ask me, whether the ASP can only run on Microsoft IIS, can you operate on a non-NT platform? I have already answered many times this question: I just heard that some kind of software that can support, but never seen it. But some enthusiastic friends still have a tireless to ask, so I am visiting the ASP-related sites under the prevalence of friends, and the ASP is indeed on other non-NT platforms, so in this The beginning of the article, I briefly introduced the friends of the letter to how to use ASP on a non-NT platform.
To develop and run the ASP application on a non-NT platform, we can rely on a third-party software called Instant ASP. Its advertising slogan is very attractive "ASP Anytime, Anywhere", I think all ASP developers look So whisper is inexpensive. This set of software developed by Halcyon Software allows you to run it on any action platform without repeated development of the original ASP application! This is not a large number of development time, and the ASP has truly become a cross-platform Internet, Intranet, or Extranet application. Instant ASP itself is actually a Java-based application, so you can run web-based ASP applications on any platform, the following table lists the operating platforms supported by Instant ASP.
What is more surprising is that INSTANT ASP not only provides ASP's operating environment, but it is more powerful and practical than the current ASP app on the current market. It combines ActiveX components and Enterprise Java Beans or CORBA-Compliant Objects. Get up, so that the ASP has a broader application. It also provides a powerful feature that connects to various databases through the ADO interface and generating dynamic pages. For developers, you can use your programming language or tools such as: Visual Basic, JScript, VBScript, C , Java, HTML, Delphi, MS Visual InterDev, etc. Regarding the specific installation and operation of Instant ASP, I will not be unfold here. Interested friends can go to its site to see HalcyonSoft.com, you can also download a trial version for free.
Following the authors introduced you to the use of the AD Rotator component, we will then look at some other ASP common components.
First, Database Access Components
The most common and most practical tasks we use to use web applications on the web server are to access the server side database. The ASP built-in Database Access component allows us to easily access information stored in a server-side database or other formalized data structure through ActiveX Data Objects (ADO). ADO is the most effective and simple and straightforward method for operating the database supported by Microsoft. It is a powerful data access programming mode that makes most data source programmable properties to be extended to your ACTIVE. On the Server page. You can use ADO to write compact scripts to connect to Open Database Connectivity (ODBC) compatible databases and OLE DB-compatible data sources, so ASP programmers can access any database compatible with ODBC, including MS SQL Server, Access, Oracle, etc. If you are a script writing personnel with a certain understanding of the database connection, you will find that the ADO command statement is not complicated and easy to master. Similarly, if you are an experienced database programmer, you will correctly understand the advanced language-independent and query processing features of ADO. Friends who are familiar with VB database programming will find that ADO and RDO (Remote Data Objects) have some similar place. But it is said that ADO's access is faster, and memory needs to be smaller. Let's briefly introduce the step of connecting the ASP's Database Access component through the ADO and operating the web database.
Step 1: Specify the database you want to connect, there are two ways of DSN and DSN-LESS.
DSN (Data Source Name Data Source Name): Create a system data source name, the method is as follows:
1. Click Start, select the Control Panel.
2, double-click the icon "32-bit ODBC", will pop up a dialog, select "System DSN"
3. Click Add to add a DSN entry, select "Microsoft Access Drive" and confirm.
4. Enter the DSN you want to specify in the "Data Source Name" field, then click "Select" to select the data inventory location, you can press "Browse" to select.
5. After the above step is completed, specify DSN in the ASP program, as follows:
<% connStr = "DSN"%>
DSN-LESS: Another way to establish a DSN by specifying the location of the database file directly in the ASP file without having to establish a DSN. Since many companies do not have their own web servers, their website is often stored on the far-end virtual server, so it is more troublesome to establish and modify the settings of the DSN. The use of the DSN-LESS method directly specifies that the remote database is just solved in the location, the method is as follows:
<%
Connstr = "dbq =" server.mappath ("Database / Source.mdb") "; defaultdir =;
Driver = {Microsoft Access Driver (* .mdb)}; driverid = 25; FIL = MS Access;
ImplicitCommitsync = YES; maxbuffersize = 512; maxscanrows = 8;
Pagetimeout = 5; saFetransactions = 0; threads = 3; usercommitsync = yes; "
%>
After you specify the database you want to connect, you can connect and open the database by the following method:
<%
Set conn = server.createObject ("AdoDb.Connection" Conn.open Constr%>
Step 2: Specify the SQL instruction you want to execute, you can use the Recordset.
When you connect the database, you can operate the database, such as query, deletion, update, etc., these operations are done by SQL instructions, as follows, in the database table DateBase, query all names "A" records:
<%
SQL = "Select * from datebase where name like 'a %%'"
SET RS = Conn.execute (SQL)
%>
Although the Connection object simplifies the connection database and query tasks, there is still a lot of shortcomings in the Connection object. Specifically, the Connection object that retrieves and displays database information cannot be used to create scripts, and you must know the changes you want to make for the database before you can use the query to make changes. For retrieval data, check results, change the database, ADO provides the Recordset object. As its name, the RecordSet object has many features you can use, retrieved and display a set of database lines according to your query restriction, and display a set of database lines. The Recordset object holds the location of the record returned by the query, allowing you to step by step by step. You can scroll and update records according to the pointer type property settings of the Recordset object. The database pointer allows you to locate a specific item in a set of records. The pointer is also used to retrieve and check the record, and then perform the operation on the basis of these records. Recordset objects have some properties that can be used to accurately control the behavior of pointers, enhance your ability to check and update results.
The use of Recordset is as follows:
SET RS = Server.createObject ("AdoDb.Recordset")
RS.Open SQL Directive, CONN, 1, 1 'Read
or
RS.Open SQL instruction, CONN, 1, 3 'new, modified, or delete
Step 3: Use the RecordSet attributes and methods and display the results of the execution.
With the above instruction, we created a cursor "RS" containing the data, and the trigger is a similar record and field of the similar records and fields stored in the active memory. When you create a cursor via the RecordSet component, it is from the data The provider gets a data set, and uses it to enrich the cursor, we can imagine the recordset generated by ADO is a record of the spreadsheet, it has a line of records, there is a line of it is its current row, and Recordset The field is represented by the Field collection of Recordset. Some of the properties and methods of the created Recordset object (cursor) are listed below:
Rs.fields.count: The total number of fields of the Recordset object.
RS (i) .name: The name of the i-th field, i is calculated from 0 to rs.fields.count-1.
RS (i): Read the data of the i-th field, i is calculated from 0 to rs .fields.count-1.
RS ("Field Name": Read the data of the specified field.
Rs.Recordcount: The total number of data records in the cursor.
rs.eof: Whether it is pointed to the last record.
Rs.Movenext: Move the indicator to the next record.
Rs.MovePrev: Move the indicator to the previous record.
Rs.MoveFirst: Move the indicator to the first record.
Rs.MoveLast: Move the indicator to the last record.
Rs.close: Turn off the Recordset object About other introductions of ADO, the author will give you a detailed explanation in the future.
Second, Content Linking Components
If your site has a series of interrelated pages, the Content Linking component will be very suitable for your needs, it doesn't make you create a directory table in these pages, and you can build dynamic connections in them, and automatically generate and Update the directory table and the navigation link for the previous and subsequent web page. This is a very ideal choice for listing online newspapers, electronic reading websites, and forum mail.
Content Linking Components Create a NEXTLINK object for the URL list. To use the Content Linking component, you must need to create the Content Linking List file first. The Content Linking component is using this file to get information about all pages that we want to link. In fact, the file is a plain text file, its contents are as follows:
Page1.htm One
Page2.htm Two
Page3.htm Three
Page4.htm Four
Page5.htm Five
Page6.htm Six
Each line of this text file has the following form:
URL Description Comment
Where the URL is a page-related hyperlink address, Description provides text information that can be used by the chain, and Comment contains annotation information that is not interpreted by the Content Linking component, its role as comments in the program. Description and Comment parameters are optional.
Let's take a look at how to specifically use the Content Linking component:
hEAD>
network electronic reading navigation
<%
Set link = server.createObject ("mswc.nextlink")
Count = line.getlistcount ("NextLink.txt")
DIM I
For i = 1 to count
%>