ASP connection database of the almighty code _ Application Skills
Source: Internet
Author: User
ASP connection database of the almighty Code
' Solve 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:
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service