Use ASP and ADO web database

zhaozj2021-02-17  51

Use ASP and ADO web database

Introduction to ASP and ADO

The VBScript, JavaScript language can be used to control the database access (and the ASP is exactly the interpretation environment of the scripting language) and the output of the query result; the use of the RecordSets object is operated using the RecordSets object; can connect a variety of databases that support the OD BC. Data check ASP (Active Server Pages) is a server-side script execution environment that can be used to generate and perform dynamic, interactive, high-performance web server applications. When the script is executed on the server, the web server will complete all the work that generates the HTML (Hypertext Markup Langua GE page to the browser. Figure 1 Figure 1 is an operation mode of the ASP. When the browser makes a request to the web server, an ASP script starts to execute. At this time, the web server calls the ASP, read all the files and executes each command, and then send the result in the HTML page. Back to the browser. ADO (ActiveX Data Object, ActiveX Data Object) is an ASP built-in A CTIVEX server component (ActiveX Server Component), used for database access, combining it with ASP, establish web content providing database information, querying the database , Insert, update, delete, etc. To perform ADO, the server is required to install Windows NT Server and Internet I Nformation Serv ER (IIS), and the client can have an IE or Netscape newer version of the browser. Several scenarios for site database access to Web database access can be roughly divided into two categories, and a class is a web server as an intermediary, connecting the browser and data source, executing the operation of the database on the server side; another class is Download the application and database to the client and perform access to the database on the client. 1. Public gateway interface CGI (Common Gateway Interface) When the browser issues an HTTP request, the web server performs the corresponding application, access the site database, and send the query to the browser in HTML format. This approach has a lot of shortcomings, limited functions, difficulties, and does not have transaction (Transaction), which limits its application. 2. Internet Database Connector IDC (Internet Database Connector) This is a simple program that is still placed on the web side for the operation of the database, but users can query, input, update, delete the database via SQL (STRUCTURED Query Language statement). Wait actions. The IDC is easy to design without compiling, and supports multiple queries of the data (Multiple Query). 3. Advanced Database Connector ADC (Advanced Data Connector) The operation of the database is performed on the server side, while the ADC is executing data query action on the browser side. When the browser makes a request for the database, the ADC first downloads the corresponding database to the browser side and operates on the user. Obviously, this solution is high. The query of the client is done by the A DC ActiveX Control installed on the client, and this ActiveX Control is automatically downloaded and installed by the site server. 4. ADO and ASP This is a complete web database access scheme that combines the ADO and ASP to establish web content providing database information, execute SQL commands in the web page, query, insert, update, delete, etc. operating. A as an example: Hong Kong and Macao ID information query This example is to complete is to query the Hong Kong and Macau Exit Database. Customers can give one or several query conditions, then display the query results as required. 1. Determine the data source to access the online database, first set the source of data. Open the "Control Panel" in "My Computer" on the server, double-click "ODBC"; "Add" to "Add" below "System DSN", select a pre-set database type, name, and location. What you want to use here is the FoxPro database, the data source name is Gacx, the main database name is Visa.dbf, the encoded database name is zd.dbf.

2. ADO Query Database Using the ADO Query Database Design method is to get an instance of the object "AdoDb.Connection" first with server.creatobject, and open the database to be accessed with "Open": set conn = server.creatobject ("AdoDB. Connection ") Conn.open" The Database Name to Access "and then execute the SQL command, that is, the database is operated, here you want to use the execute command: set = conn .execute (" SELECT ...WM ... WHERE ... ") Next, you can query the database, you can use the following command to use the RECORDSETS object: * rs.Fildes.count Recordsets * rs (i) .name orthical i-th field name * RS (i) 第 第Record of a field * RS ("Field Name") Specified field record * rs.eof does not point to the last field true or false * rs.movefirst points to the first record * rs.MovePrev points forward a record * rsmovenext point The latter record * rs.movelast pointing to the last record * rs.getrowS stores the query results in an array, then read from the array * rs.properties.count Get ADO's Connection or ResultSet's total number of properties * rs.properties Item) .Name Gets ADO's Connection or Resultse T of the Property Name * rs.properties (Item) Get ADO's Connection or ResultSet's property value 3. The main page is the Hong Kong and Macao ID information query, the corresponding program is gacx.asp. The results of the query are displayed in two ways. First, the main information - Hong Kong and Macao ID information query results list, the corresponding program is gacxlb.asp; one is to display all information - Hong Kong and Macao ID information query results, the corresponding program is gacxxq.asp. If the query criterion is not satisfied, a hint page will also be displayed, telling the user that there is no result of satisfying the condition, and is done by the program gacxts.asp. Establish queries, query results, query results list pages, and give a simple prompt interface, tell the user that there is no condition for satisfying the condition, please re-query, these work can be used by FrontPage 98 Completed, the entire page should be simple and generous and the theme is clear. The program code is written under Microsof T Visual I NterDev. The content encoding the database zd.dbf is processed below. From Figure 2, there are many options with a drop-down box, such as "gender", "birthplace", etc., these options are extracted from the zd.d bf database. Because some options have a lot of content, such as 101 outbound ports, although you can also use "do while not r s.eof response.write"

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

New Post(0)