'Solved the problem of ACCESS database path!
'Use DBType=0 or DBType=1 to distinguish AC library or MSSQL library
'For specific matters that should be paid attention to when using the AC library, please see the program description
---------------------------------- ----------
Dim DBType,Conn,StrConn
DBType=0 '0 is Access database, 1 is MSSQL database
If(DBType=0) Then
'******************ACCESS DATABASE******************
Dim DbFolderName,DbFolder_Path,SiteFolder
DbFolderName="ArticleData" 'Name of the folder where the database is located
DbFolder_Path = Server.MapPath(DbFolderName) 'The path to the database
SiteFolder="Article" 'The name of the root directory where the system is locatedIf
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)};DBQ=" & Session("RootDir") & ""& DbFolderName & "Data.mdb" 'Connect to the 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="local" 'The address of the database, if it is a local database: (local)
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 setting error******************
Response.Write "Database setting error, please contact the administrator!"
Response.End
End If
'Response.WriteStrConn