What is the way ASP accesses a database?
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.
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.