1. Compared with the older environment, it is recommended to use a second
Set Dbconnection=server.createobject ("ADODB. CONNECTION ")
DBPath = Server.MapPath ("Customer.mdb")
DbConnection. Open "Driver={microsoft Access driver (*.mdb)};d bq=" & DBPath
Sql= "SELECT * from auth where id= '" & user_id & "'"
SET uplist=dbconnection. EXECUTE (SQL)
2.win2003 above machines, this method is recommended to be more efficient
Set Dbconnection=server.createobject ("ADODB. Connection ")
DBPath = Server.MapPath ("Customer.mdb")
DbConnection. Open "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" &dbpath
Sql= "SELECT * from auth where id= '" & user_id & "'"
SET uplist=dbconnection. EXECUTE (SQL)
3.
DBPath = Server.MapPath ("Customer.mdb")
Set session ("RS") =server.createobject ("ADODB"). Recordset ")
' Rs=server.createobject (ADODB. Recordset ")
Connstr= "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" &dbpath
Sql= "SELECT * from auth where id= '" & user_id & "'"
Session ("RS"). Open sql,connstr,1,3
4.
Build ODBC source XXX
Set Conn=server.createobject ("Adodb.connection")
Conn.Open "DSN=XXX; uid=; pwd=;D Atabase=customer
5, attach a frequently used SQL Server and access common Connection database code
Copy Code code as follows:
<%
Const databasetype=1
If Databasetype=0 Then
Dbpath= "/jb51/news.asp"
Sqlnowstring = "Now ()"
Ystr=true
Nstr=false
Suiji= "Rnd (ID)"
Else
' If it is a SQL database, please carefully modify the following database options
DataServer = "wwwjb51net" ' Database server IP
Datauser = "Jb51net" ' Access to database user name
DataBaseName = "Jb51net" database name
DATABASEPSW = "Password" access to the database password
sqlnowstring = "getdate ()"
Ystr=1
Nstr=0
Suiji= "newid ()"
End If
On Error Resume Next
If DatabaseType = 1 Then
Connstr= "Driver={sql server};server=" "&dataserver&"; Uid= "&datauser&"; Pwd= "&databasepsw&";D atabase= "&databasename
Else
ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath (DBPath)
End If
Set conn = Server.CreateObject ("ADODB. Connection ")
Conn.Open ConnStr
If ERR Then Err.Clear:Set conn = Nothing:Response.Write database connection error, check the database parameter settings in the Conn.asp file. ": Response.End
%>