Implementation of ASP database connection
Xiachuntao
(102 Department of Electronic Technology College, PLA Information Engineering University, Zhengzhou 450004, Henan)
(email:xct-tom@tom.com)
Absrtact: This paper gives a variety of implementation methods of database connection in ASP.
Keywords: asp;ado;ole-db;odbc; database connection
1 Introduction
ASP is one of the most popular web program design technologies, it uses ADO technology to access the database. ADO is Microsoft's main data access technology, which is the result of the evolution of Microsoft's various data access technologies, such as ODBC, DAO, RDO, ole-db, and so on.
ADO is a COM object that encapsulates a ole-db complex interface, and it accesses a variety of different data with a very simple COM interface. Figure 2 is a schema diagram for ADO data access. As can be seen from the diagram, ADO can access data from different data sources directly by OLE-DB, or it can indirectly access data from relational data sources by ODBC. In this paper, the implementation of database connection in ASP application is preliminarily discussed in these two ways.
Figure 1 ADO Data Access architecture
Application/browser
Ado
Ole-db
Odbc
SQL Data
Non SQL Data
Mainframe and
Legancy Data
2 Connection objects
The connection object in ADO represents a connection to the underlying data supply program, which maintains information about the data supply program. In an ASP application environment, the connection object represents a connection from the Web server to the database server. The connection object calls the open method to implement a connection to the database, and its syntax is as follows:
Connection.Open [Connectionstring],[userid],[password],[options]
The parameters and descriptions of the Open method are shown in table 1:
Table 1 parameters and descriptions of the Open method
Parameters
Description
ConnectionString
A string that contains the details of the connection. Can be the name of the ODBC DSN, the name of the data link file, or the actual connection details. Optional parameters.
Userid
The name used by the user during the connection. Overrides any user name provided in the connection string. Optional parameters.
Password
The password for the user. Overrides any password provided in the connection string. Optional parameters.
Options
Can be adasyncconnect, which specifies that the connection be established asynchronously. Ignoring this parameter, a synchronous connection is established. Note: Because the scripting language cannot receive events from ADO, asynchronous connections are not used in an ASP environment, and this parameter is generally ignored.
As you can see from table 1, the key to connecting the Open method to the database is to give the correct connectionstring. The following is an example of a SQL Server2000 database, giving the connectionstring of various connection modes.
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.