15th Common ASP ActiveX components

Source: Internet
Author: User
Tags count data structures implement connect odbc prev web database microsoft iis
When you use ASP to write server-side applications, you must rely on ActiveX components to powerful WEB application functions, such as: you need to connect the database, the database online operation, etc., following the introduction of the AD Rotator components, this article will then introduce some other common ASP a   How the Ctivex component is used. A lot of friends have recently written to ask me whether ASP can operate on a non-NT platform only on Microsoft IIS. I've answered this question many times before: I've just heard of some kind of software that I can support, but I've never seen it. But some enthusiastic friends continue to write to ask, so in the hospitality of friends, I visited the ASP related sites, unexpectedly surprised to find that the original ASP is really can run on other non-NT platform, so at the beginning of this article, I will give a letter to the friends briefly how to use on non-NT platform   Asp. To develop and run an ASP application on a non-NT platform we can rely on a set of Third-party software called Instant ASP, its advertising slogan is very attractive "ASP anytime, Anywhere", I think all ASP developers see such slogans must be excited. The software developed by Halcyon Software company allows you to run it on any platform without duplicating the original ASP application! This saves a lot of development time and makes the ASP truly a cross-platform Internet, Intranet, or Extranet application. Instant ASP itself is actually a suite of java-based applications, so you can run a web-based ASP application on any platform, and the following table lists the operating platforms supported by the current version of Instant ASP. More surprisingly, Instant ASP not only provides an ASP's operating environment, but also provides a more powerful and practical feature than the current ASP application on the market, which will ActiveX components and Enterprise Java Beans or Corba-complian T objects together, so that the ASP has a more extensive application. It also provides the ability to access various databases through the ADO interface and generate dynamic pages. For developers, you can use a programming language or tools that you are good at: Visual Basic, JScript, VBScript, C + +, Java, HTML, Delphi, MS Visual InterDev and so on to develop.   About Instant ASP specific installation and operation I'm not here to start, interested friends can go to its site to see halcyonsoft.com, you can download a trial version of the free try.    Following the previous article about the use of the AD Rotator component, let's take a look at some other ASP-common components today. One, database access components The most common and most practical task we use Web applications on a Web server is to access the server-side database. The database access component built into ASP allows us to easily access information stored on server-side databases or other tabular data structures through ActiveX data Objects (ADO). ADO is the most efficient and straightforward way to operate a database currently supported by Microsoft, a powerful data access programming model that allows most data source programmable properties to be extended directly to your Active Server page. You can use ADO to write compact and concise scripts to connect to Open database Connectivity (ODBC)-compliant databases and OLE DB-compliant data sources, so that ASP programmers can access any ODBC-compliant database, including MS SQL SERVER, Access, Oracle, and so on. If you are a scripting person with a certain understanding of database connections, you will find that the ADO command statements are not complex and easy to master. Similarly, if you are an experienced database programmer, you will correctly understand the advanced language-independent and query-processing capabilities of ADO. Familiar with VB database programming friends will find ADO and RDO (Remote Data Objects) have some kind of place.    But ADO is said to be accessing faster and less memory.    Here's a brief introduction to using ASP's database Access component to connect to and manipulate a WEB database through ADO Step one: Specify the database you want to connect to, with DSN and dsn-less two methods.    DSN (data source name): Establish a System data source name as follows: 1, click Start, select Settings Control Panel.   2, double-click the icon "32-bit ODBC", will pop up a dialog box, select the tag "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" column, and click "Select" to select the database storage location, which you can select by clicking "Browse". 5, after the completion of the above steps in the ASP program to specify DSN, as follows: <%CONNSTR = "DSN"%> dsn-less: is another way to specify the location of a database file directly in an ASP file without having to establish a DSN. Since many companies do not have their own web servers, their Web sites tend to be stored on remote virtual servers, so setting up and modifying DSN settings can be tricky. Using the Dsn-less method to specify the location of the remote database directly solves the problem, as follows: <% CONNSTR = "dbq=" +server.mappath ("Database/source.mdb") + ";D efaultdir=; Driver={microsoft Access DRIVER (*.mdb)};D riverid=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 to, you can connect and open the database by using the following methods: <% Set Conn = Server.CreateObject ("ADODB".   Connection ") Conn.Open constr%> Step Two: Specify the SQL instructions you want to execute, and you can use the RecordSet. When you connect a database, you can manipulate the database, such as queries, deletes, updates, and so on, which are done through SQL instructions, and in the following example, in database table datebase, query all names with a record of "a": <% sql= "SELECT * from Dateba SE where name like ' a%% ' "Set rs = conn.execute (sql)%> Although Connection object simplifies connection database and query tasks, but there are still many deficiencies in the Connection object. To be exact, a Connection object that retrieves and displays database information cannot be used to create a script, and you must know exactly what changes you want to make to the database before you can use the query to implement the changes. ADO provides a Recordset object for retrieving data, checking results, and changing the database. As its name implies, the Recordset object has many features that you can use, and, depending on your query restrictions, retrieves and displays a set of database rows, that is, records. The Recordset object retains the location of the records returned by the query, allowing you to scan the results one at a time. Depending on the pointer Type property setting of the Recordset object, you can scroll and update the record. A database pointer lets you navigate to a specific item in a set of records. Pointers are also used to retrieve and check records, and then perform actions on the basis of those records.    The Recordset object has properties that can be used to precisely control the behavior of the pointer and improve your ability to examine and update the results. The Recordset is used as follows: Set rs = Server.CreateObject ("ADODB. Recordset ") Rs. Open SQL instruction, Conn, 1, 1 ' Read or Rs.   Open SQL directives, Conn, 1, 3 ' Add, modify, or remove the third step: Use the RecordSet properties and methods and display the results of the execution. With the instructions above, we created a cursor (RecordSet) "RS" containing data, in fact a cursor is something that is stored in an array of similar records and fields in active memory, and when a cursor is created through the RecordSet component, it obtains a dataset from the provider of the data, and using it to enrich the cursor, we can imagine that the recordset produced by ADO is a record like a spreadsheet, it has a row of records, and at any time a row is its current row, and the recordset's fields are represented by the recordset's field collection. Some properties and methods of the RecordSet object (cursor) that you create are listed below: Rs.    The total number of fields for the Fields.Count:RecordSet object. RS (i). Name: The names of the I fields, I count from 0 to Rs.    Fields.count-1. RS (i): reads the data of the first field, I from 0 to Rs.    Fields.count-1. RS ("field name"): Read the specified fieldof data. Rs.    RecordCount: The total number of data records in the cursor. Rs.    EOF: Whether the last record has been indicated. Rs.    MoveNext: Moves the metric to the next record. Rs.    MovePrev: Moves the metric to the previous record. Rs.    MoveFirst: Moves the metric to the first record. Rs.    MoveLast: Moves the metric to the last record. Rs.   Close: Closes the RecordSet object For more information about ADO, the author will give you a detailed explanation in the future. Ii. Content Linking components If your site has a series of interrelated pages, the content Linking component will suit your needs, not only can you create a table of contents on these pages, but you can also create dynamic connections between them. and automatically generate and update catalog tables and navigation links to previous and subsequent Web pages.   This is an ideal choice for listing online newspapers, electronic reading sites, and forum mail. The content Linking component creates a Nextlink object that manages the URL list, and to use the content Linking component, you must first create the content Linking List file. The Content linking component is reading this file to get information about all the pages we want to link to. In fact, the file is a plain text file, which reads as follows: Page1.htm one page2.htm two page3.htm three page4.htm the four page5.htm five the page6.htm of this text file every The line has the following form: URL description comment The URL is a hyperlink address that is related to the page, description provides text information that can be used by the hyperlink, and comment contains an explanation of the Content linking component. annotation information, which acts as a comment in a program.    The description and comment parameters are optional. Let's look at how to use the Content linking component: < Html> < head> < meta http-equiv= "Content-type" content=; charset=gb2312 "> < TItle> Network Electronic Books Treasure </title>


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.