ASP ActiveX Components

Source: Internet
Author: User
Tags data structures dsn odbc query microsoft iis
Active|activex 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, and so on, following the introduction of the AD Rotator components, this article will then Show you how to use other common ASP ActiveX components.

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. Developers can use their own programming languages or tools such as visual Basic, JScript, VBScript, C + +, Java, HTML, Delphi, MS Visual InterDev, and so on. 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.

Today we'll take a look at some other ASP-common components.

One, Database Access components

The most common and practical task we use with 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 WEB databases via ADO

The first step: 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 the 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 directly specify the location of the remote database solves this problem, 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 directly specify the location of the remote database solves this problem, as follows:

<%
Connstr= "dbq=" +server.mappath ("Database/source.mdb") + ";D efaultdir=;D river={microsoft Access DRIVER (*.mdb)};"
%>

After you specify the database that you want to connect to, you can connect to and open the database in the following ways:

<%
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 to a database, you can manipulate the database, such as queries, deletes, updates, and so on, which are done through SQL instructions, as in the following example, in the database table datebase, query all names with a record of "a":

<%
Sql= "SELECT *" datebase where name like "a%%"
Set rs = conn.execute (SQL)
%>

Although the Connection object simplifies the connection database and query tasks, 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 in the following ways:

Set rs = Server.CreateObject ("ADODB.") Recordset ")
Rs. Open SQL directive, Conn, 1, 1 read
Or
Rs. Open SQL directive, Conn, 1, 3 "New, modified, or deleted

[1] [2] Next page



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.