ASP and database, text file link
First, link with SQL (via ODBC):
1. First set the SQL database to be connected by setting the setting ODBC source in the control panel, get a name SQL Sever after the connection is successful, such as Zou
2. Then use the editor (such as Notepad), join
<%
Set dbconn = server.createObject ("adoDb.connection")
Dbconn.open "Server Name", "User Name", "Password" // If you set a password, you want to enter, otherwise just the dbconn.open "server name" (herein refers to the name generated by the ODBC link, as above Zou. )
Sqlcmd = "SELECT * FROM Table Name" (here the table name refers to the table name in the database)
SET RS = dbconn.execute (SQLCMD) // All data in the table specified in the database are in RS.
................
Rs.close
Dbconn.close
%>
Second, directly connected to SQL7.0, no need to set an ODBC source:
Edit the following with text editor:
<%
Set dbconn = sever.createObject ("adoDb.connection")
Connstr = "provider = sqloledb.1; server = zou; uid = username; PWD = password; Database = Database name"
Dbconn.open connStr
Sqlcmd = "Select * The table name in the country" // for the SQL instruction you want to execute;
SET RS = dbconn.execute (SQLCMD) // Record in the database is all in RS
..........
Rs.close
Dbconn.close
%>
Third, connect Access database via ODBC source:
1. Set the ODBC name of Access in the "ODBC source" in the control panel.
2. Enter the text editor:
<%
Set dbconn = server.create ("adoDb.connection")
DBCONN.Open "Access's ODBC Name"
SQLCMD = "SELECT * FROM table name"
SET RS = dbconn.execute (SQLCMD)
.........
Rs.close
Dbconn.close
%>
Fourth, directly with Access database:
<%
Set dbconn = server.createObject ("adoDb.connection")
Connstr = "driver = {Microsoft Access Driver (* .mdb)}; dbq =" & Server.mappath ("Path" of the Store ") &" Database Name "(EG: Connstr =" DRIVER = {Microsoft Access Driver (* .mdb)}; dbq = "& server.mappath (" / 666 ") & http://www.mdb; /
Dbconn.open connStr
SQLCMD = "SELECT * FROM Name" // SQL instruction for you want to perform
SET RS = conn.execute (sqlcmd) // The data in the table is in RS.
.......................
Rs.close
Dbconn.close
%>
V. Link Text file
<%
Set dbconn = server.createObject ("adoDb.connection")
CONNSTR = "driver = {Microsoft Text Driver (*. txt; *. csv)}; dbq =" & server.mappath ("text file path")
Dbconn.open connStr
SQLCMD = "...."
........
Dbconn.close
%>
6. Link Excel 2000:
<%
Set dbconn = server.createObject ("adoDb.connection")
Connstr = "Driver = {Microsoft Excel Driver (*. xls)}; dbq =" & server.mappath ("path name / file name")
Dbconn.open connStr
SQLCMD = "... .."
SET RS = dbconn.execute (SQLCMD)
........
Rs.close
Dbconn.close
%>
Note: The connection between the above ASP and data is the default script interpretation language (VBScript) of ASP (Active Server Page), while installing PWS (Windows 98), IIS (Windows 2000), running directly on the server. And pay attention to the list of directorys and the PWS // IIS service directory.
Disclaimer: The above is running in the simplified body Windows 98 PWS and the Simple Body Windows 2000 IIS.
Direct copying the above programs cannot be used, remember!