Data | Database Introduction
This paper describes the most basic and critical part of "Database file invocation" in ASP programming, and discusses some skills of database file invocation in ASP programming.
Introduction to ASP
ASP (Active Server Pages) is a Web application development technology launched by Microsoft in 1996, a synthesis of scripting languages, ActiveX components, and HTML languages, which Microsoft describes as "a server scripting environment where you can generate and run dynamic, Interactive, high-performance Web server application. Its main function is to provide a powerful way or technology for generating dynamic, interactive Web server applications. The feature is that both commands and scripts are interpreted in the server, and then the content sent to the client browser is just the standard HTML page. Its advantage is that the program design is simple and easy to understand, and convenient and quick. ASP in the domestic application has been very common, a considerable part of the dynamic Web site are using the ASP technology.
Calls to ASP database files
Although different system may install different database driver, but the general server system basically supports iis4.0/5.0, so the server system will have at least Microsoft Access Driver, Microsoft ODBC for Oracle, SQL Server and other 3 kinds of database drivers. Therefore, the server system can use at least 3 kinds of databases, such as access, Oracle, SQL Server, to work on ASP Web database design. Because Microsoft Access 97/2000 is part of Microsoft's Office family, and the interface is similar to the Office family of software, there is little or no barrier to learning, so this article uses an Access database file for ASP programming from a beginner's point of entry.
Make a database file (Friend.mdb) as shown in Figure 1 through an Access application
Then, there are two ways to invoke the database file in ASP programming, one is manually set directly on the data source (ODBC) in Control Panel, and the other is programming to invoke the database file through a relative path, which can be applied on any server without further configuration. The first approach is simpler and safer, and this is the second way.
The following is a list of methods for general reading of table records in the database file in ASP programming:
: <HTML> <BODY>
!--#include file= "Adovbs.inc"-->
03: <%
04: ' Use ASP's connection object to open the database, the database file is the image of the <Friend.mdb> '
05:dim objconn
06:set objconn=server.createobject ("ADODB"). Connection ")
07:objconn.connectionstring= "Provider=Microsoft.Jet.OLEDB.4.0;" &_
"Data source=" & Server.MapPath ("Friend.mdb")
09:objconn.open
10: Read the records of the "Data" table and store it in the record set object
11:dim objRS
12:set objrs=server.createobject ("ADODB"). Recordset ")
13:objrs.open "Data", objconn,adopenkeyset,adlockoptimistic,adcmdtable
14: ' Display the record that the current pointer refers to on the browser
15:if not objRS. EOF Then
16:response.write "No.:" &objrs ("number") & "<BR>"
17:response. Write "Name:" &objrs ("name") & "<BR>"
18:response. Write "Sex:" &objrs ("Gender") & "<BR>"
19:else
20:response.write "to the end of the database, all records that meet the criteria have been displayed."
21:end If
22: ' Close the database connection and release the object instance
23:objrs. Close
24:set objrs=nothing
25:objconn.close
26:set objconn=nothing
27:%>
</BODY> </HTML>
The code above is the design step for generally opening an Access database file in ASP programming.