Connection database ' solves the problem of Access database path!
' Use dbtype=0 or dbtype=1 to differentiate between the AC library and the MSSQL Library
"The specific use of the AC library should pay attention to matters, please see the program description
--------------------------------------------------------------------------------
Dim Dbtype,conn,strconn
Dbtype=0 ' 0 is an Access database, and 1 is a MSSQL database
If (dbtype=0) Then
' ********************************access database *************************************
Dim Dbfoldername,dbfolder_path,sitefolder
Dbfoldername= folder name of "Articledata" database
Dbfolder_path = Server.MapPath (dbfoldername) ' The path to the database
Sitefolder= name of the root directory where the "Article" system resides
If session ("RootDir") = "" Then
Session ("RootDir") = Mid (Dbfolder_path, 1, INSTR (1,dbfolder_path,sitefolder,1)-1) & Sitefolder
End If
Set Conn = Server.CreateObject ("Adodb.connection")
strconn = "Driver={microsoft Access Driver (*.mdb)};D bq=" & Session ("RootDir") & "\ & Dbfoldername &" \dat A.mdb "' Connect to Database
Conn.Open strconn
'**********************************************************************************
ElseIf (dbtype=1) Then
' *****************************mssql Server database *************************************
Dim Dbuserid,dbpassword,dbname,dbip
' Modify the following information to suit your site
dbuserid= "sa" ' Database login name
dbpassword= "" ' Database password
Dbname= "dbname" database name
Dbip= the address of the "local" database and, if it is a native database:
Set conn=server.createobject ("Adodb.connection")
strconn = "Provider=SQLOLEDB.1;Data source=" &DBIP&; Initial catalog= "&DBName&"; Persist Security info=true; User id= "&DBUserID&"; Password= "&DBPassWord&"; Connect timeout=30 "
Conn.Open strconn
'**********************************************************************************
Else
' *********************** Database Setup Error *************************************************
Response.Write "Database Setup error, please contact admin!" "
Response.End
End If
' Response.Write strconn