1, database connection.
ASP to connect to an Access database:
<%@ language=vbscript%>
<%
Dim conn,mdbfile
Mdbfile=server.mappath ("database name. mdb")
Set Conn=server.createobject ("Adodb.connection")
Conn.Open "Driver={microsoft Access Driver (*.mdb)};uid=admin;pwd= database password; dbq=" &mdbfile
%>
ASP to connect to SQL database:
<%@ language=vbscript%>
<%
Dim conn
Set Conn=server.createobject ("Adodb.connection")
Con.open "Provider=sqloledb;data source=sql server name or IP address; Uid=sa; pwd= database password; database= database name
%>
The DW uses string concatenation code:
"Driver={microsoft Access Driver (*.mdb)};D bq= Absolute path to the database"
When you are done, open the database server and
"Driver={microsoft Access Driver (*.mdb)};D bq= Absolute path to the database"
Into
"Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath ("Database path under Server root directory")
and modify the local server into a test server
2, loading other pages.
<!--#include file = "path and name of page"-->
3, display the data in the database.
<%=rs ("field")%>
4, output.
Response.Write ("literal or string");
5. Open the database and set up the DataSet object.
Set Conn=server. CreateObject ("Adodb.connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" &server. MapPath ("***/photodata.mdb") ' Change your database file storage path
Set Rs=server.createobject ("Adodb.recordset") ' establishes a dataset
Sql= "SELECT * from data" To change your database table name
Rs. Open sql,conn,1,1
6, to obtain the system time.
<%=now ()%>
7, to obtain access to the IP.
<%=request.servervariables ("Remote_host")%>
8, random number.
<%randomize%>
<%= (int (rnd () *n) +1)%>
N is a number that can be changed
9, jump page.
Response.Redirect ("page")
10, pop-up message box.
Response.Write ("<script>alert") (' message box! ') </script> ")
Current 1/2 page 12 Next read the full text