1. Database connection.
Connect ASP to Access database:
<%@language=VBscript%>
<%
dimconn,mdbfile
mdbfile=server.mappath("database name.mdb")
setconn=server.createobject("adodb.connection")
conn.open"driver={microsoftaccessdriver(*.mdb)};uid=admin;pwd=database password;dbq="&mdbfile
%>
ASP and SQL database connection:
<%@language=VBscript%>
<%
dimconn
setconn=server.createobject("ADODB.connection")
con.open"PROVIDER=SQLOLEDB;DATASOURCE=SQL server name or IP address;UID=sa;PWD=database password;DATABASE=database name
%>
Concatenate codes with strings in DW:
"Driver={Microsoft AccessDriver(*.mdb)};DBQ=Absolute path to the database"
After finishing, open the database server and
"Driver={Microsoft AccessDriver(*.mdb)};DBQ=Absolute path to the database"
Change to
"Provider=Microsoft.Jet.OLEDB.4.0;datasource="&server.mappath("Database Path under the server root directory")
And modify the local server to test server
2. Load other pages.
<!--#includefile="Page Path and Name"-->
3. Display the data in the database.
<%=rs("field")%>
4. Output.
Response.Write("Text or String");
5. Open the database and create the dataset object.
setconn=server.CreateObject("ADODB.connection")
conn.open"Provider=Microsoft.Jet.OLEDB.4.0;DataSource="&server.MapPath("***/photodata.mdb")'Change your database file storage path
setrs=server.createobject("ADODB.recordset")'Create the dataset
sql="SELECT*FROMdata"'Change your database table name
rs.Opensql,conn,1,1
6. Obtain the system time.
<%=now()%>
7. Obtain the IP to access.
<%=request.serverVariables("remote_host")%>
8. Random number.
<%randomize%>
<%=(int(rnd()*n)+1)%>
N is the variable number
9. Jump to the page.
Response.Redirect("page")
10. A message box pops up.
Response.Write("<script>alert('Message box!')</script>")
12Next page Read the full text