Several practical methods for pages and database connections in ASP

xiaoxiao2021-03-06  60

Several practical methods for implementing page and database connections in ASP

Yan Zhongxiao Subsequent Xiaolong (Urumqi Army College Fighting Laboratory 830002) Abstract: This article discusses several practical methods for pages and database connections in the ASP, and finally gives examples of the function to access the SQL Server database using this article. It is important to develop network automation systems. Keywords: ASP database connection On Internet Online, you can see the message board, discussion group, online voting, online survey, chat room, etc., and a variety of office automation network systems in many units of small LANs. These programs are implemented using ASP (Active Server Page) and database technology. The page and database source establishment is a step in accessing the database and is also a one in the most important step. In the ASP script, you can connect the database through three practical methods: Connects through the ODBC DSN, establish a connection through the OLEDB and establish a connection via Driver. First, establish an ODBC DSN to establish an ODBC data source, first must set the data source in the ODBC of the control panel, and then write the script and database source establishment. 1. Creating an ODBC DSN Opens the Control Panel by Windows's Start menu, and you can create DSN-based files. Double-click the "ODBC" icon, then select the System DSN property page, click Add, select the Database driver, and then click Next. Follow the instructions to configure the DSN for your database software. Common database software has Microsoft Access and SQL Server, here, here as an example of SQL Server database. Configuring SQL Server Database System DSN: Note If the database resides on the remote server, contact the server administrator to get additional configuration information; the following procedure uses SQL Server's ODBC default settings, it may not apply to your hardware Configuration. In the Create New Data Source dialog box, select "SQL Server" from the list box, and then click Next. Type the name of the DSN file and click Next. Click Finish to create a data source. Type the name of the server running the SQL service program, log in to the ID and password. In the "New Data Source" dialog box "Create SQL Server" dialog, type the name of the server containing the SQL Server database in the Server list box, and then click Next. Select the way to verify the login ID. If you want to select SQL Server Verification, enter a login ID and password, and then click Next. In the "New Data Source" dialog box "Create SQL Server" dialog box, set the driver and ansi ID of the default database, store the procedure setting, and then click Next. (To get more information, click Help.) In the dialog (the new data source named "Create SQL Server"), select a character conversion method, and then click Next. (For more information, click Help.) In the next dialog (the new data source named "Create SQL Server"), select the login setting. Note that you can only use logs to debug database access issues.

In the ODBC Microsoft SQL Server Installer dialog box, click Test Data Source. If the DSN is correctly created, the Test Results dialog box will point out the completion of the test. 2. Writing scripts and database sources establish a connection ADO (ActiveX Data Objects) Provides a Connection object, which can use this object to establish and manage connections between applications and ODBC databases. The Connection object has a variety of properties and methods that can be used to open and close the database connection. Write a database connection script, first create an instance of the Connection object, then open the database connection: <% set conn = server.createObject ("adoDb.connection" conn.open "DSN = ODBC name; Database = database name; uid =; PWD =; "%> 2, establish the connection through the OLEDB method to create the connection to the database with the database, do not need to create an ODBC DSN data source, and write directly to the following scripts and data source establishment, is a simple and easy-to-use method. <% set conn = server.createObject ("adoDb.connection") conn.open "provider = SQLOLDB; server = (SQL server name or IP address); database = database name; UID =; pwd ="%> three, pass Driver is established to connect to the DRIVER to create a connection to the database, and do not need to create an ODBC DSN data source, but you must know the actual database file path or data source name (for example, a SQLServer database). <% set conn = server.createObject ("adoDb.connection" conn.open "driver = {sql server}; server = (SQL server name or IP address); database = database name; uid =; pwd ="%> Fourth, instance (landing system), whether entering the forum, or entering an automation management system, users need to fill in login information, and check if there is such a user's registration information in their own database, if detected, the user can Successfully log in. The implementation of this login checkup requires the connection of the background database to the front desk page. Code Implementation: Connection script program can be written separately as a page name conn.asp, you can quote it. You can also write directly in the login check page.

转载请注明原文地址:https://www.9cbs.com/read-88617.html

New Post(0)