Common Ways to Access database

Source: Internet
Author: User
Tags format functions iis odbc sql query access database client
Access to | data | What are the ways in which databases are accessed by ASP?

The database can be accessed in three ways in asp:
1, IDC (Internet Database Connector) way;
2, ADO (ActiveX Data Objects) way;
3, RDS (Remote Data Service) mode.
All three accesses to the database are performed by the Internet Information Server. Using the HTTP protocol to send requests to IIS (Internet Information servers) through a Web browser, IIS performs access to the database and returns a document response in HTML format. The following are described separately:
1, IDC (Internet Database Interface)
IDC is a traditional database query tool that defines and executes SQL commands for database queries, and returns a page with the specified data format to the browser. The most important feature of using IDC to access a database is that it is simple and requires little programming to access the database.
IDC uses two files to control how to access a database and how to create a returned Web page: The IDC (. idc) file and the HTML extension (. htx) file. The. idc file must include an ODBC data source (Datasource), The file name (Template) of the HTML extension file and the SQL statement to execute (sqlstatement). In addition, there are many optional fields that can be selected as needed.
The. htx file is an HTML document with additional tags enclosed in <%%> or <!--%%--> that IDC uses to add Dynamic Data to the document. There are six keywords (begindetail, enddetail, if, else, endif, and "%z") in the. htx file to control how the data in the database is merged with the HTML format in the. htx file. The database column name describes what data in the HTML document is returned.
In order to perform an IDC query, it is common practice to embed a connection to an. idc file in an HTML file. For example, we can use the following HTML statement to make a request to the Web server to execute the IDCTEST.IDC file:
<a href= "HTTP://LOCALHOST/IDCTEST/IDCTEST/IDCTEST.IDC" > Query </A>
When the Web server receives a request, it calls Httpodbc.dll (IDC), connects to a certain data source, and passes the SQL command to the database. When the SQL statement is executed, IDC integrates the returned data into the. htx file. IDC then returns the document to the Web server, and the Web server returns to the browser.

2, ADO (ActiveX Data Object)
ADO accesses the database more like writing a database application. It encapsulates most of the database operations in seven objects and programmatically invokes them in the ASP page to perform the corresponding database operations.
ADO is one of the core of ASP technology, it embodies the rich and flexible database access function of ASP technology. ADO has established a scripting model for accessing databases based on Web, which not only supports the core functions of any large database, but also supports the proprietary features of many databases.
ADO uses the native data source to access the database through ODBC. These databases can be relational databases, text databases, hierarchical databases, or any database that supports ODBC. The main advantage is ease of use, high speed, memory footprint and low disk space, so it is ideal for server-side database access technology. In contrast to the CGI program accessing the database, it is multi-threaded and, in the case of a large number of concurrent requests, can also maintain the efficiency of the server, and through the connection pool (Connection pool) technology and full control of the database connection resources to provide efficient connection and access to the remote database, It also supports transaction processing (Transaction) to develop efficient, highly reliable database applications.
Typically, an ASP script that accesses a database using ADO should use the connection object to establish and manage a connection to a remote database, provide a flexible query with a command object, and use the Recordset object to access the results returned by the database query. These three are the most central objects of ADO.
As with IDC, the common practice of running the database access script is to embed an. asp file in an HTML file. For example, a request is made to the Web server with an HTML statement requiring the execution of the intels.asp file:
<a href= "http://LocalHost/idctest/ado/intels.asp" > Query </A>

3. RDS (Remote Data Service)
In IIS 4.0, RDS integrates with ADO and uses the same programming model to provide access to remote databases. Although ADO can provide very powerful database access capabilities, it does not support data remote operations (Remoting). It can only execute queries and return the results of the database query, which is static, and the database on the server has no live connection to the data that the client sees. If the client needs to modify the database, it must construct the SQL statement that modifies the data and execute the corresponding query. RDS supports data remote operations. Not only does it execute queries and returns database query results, it can "move" the server-side data to the client, and call a database update command to write the modified data back to the database, like using a local database.
The bottom of RDS is called ADO to do, and also has the ease of use of ADO, except that RDS needs to be used with data-bound controls, such as the Sheridan ActiveX DataBound grid control. Just as ADO is similar to the RDO in VB, RDS is similar to the Remote Data Control (RDC) in VB.
Based on ADO, RDS provides the client with stronger data expressiveness and remote data manipulation functions by binding data display and manipulation controls. It can be said that RDS is currently the best web-based access to remote databases.



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.