MS Access數據庫連接
用DSN連接並且沒有用戶名和密碼
<%
set conn = Server
CreateObject(
ADODB
Connection
)
conn
open
YourDSNName
%>
用DSN連接並且有用戶名和密碼
<%
set conn = Server
CreateObject(
ADODB
Connection
)
conn
open
YourDSNName
username
password
%>
用實際的數據庫絕對路徑連接
<%
Set conn = Server
CreateObject(
ADODB
Connection
)
Strconn=
DRIVER={Microsoft Access Driver (*
mdb)};
Strconn=Strconn &
DBQ=e:\yanhang\database
mdb
conn
Open Strconn
%>
用實際的數據庫相對路徑連接
<%
Set conn = Server
CreateObject(
ADODB
Connection
)
Strconn=
DRIVER={Microsoft Access Driver (*
mdb)};
Strconn=Strconn &
DBQ=
& Server
MapPath(
/database/yanhang
mdb
)
conn
Open Strconn
%>
MS SQL Server數據庫連接
用DSN連接
<%
set conn = Server
CreateObject(
ADODB
Connection
)
conn
open
DSN=MyDSN;UID=user;PWD=password;DATABASE=databasename
%>
不用DSN連接
<%
Set conn = Server
CreateObject(
ADODB
Connection
)
DSNtemp=
DRIVER={SQL Server};SERVER=ServerName;UID=USER;PWD=password;DATABASE=databasename
conn
open DSNtemp
%>
FoxPro數據庫連接
<%
Set Conn = Server
CreateObject(
nnection
)
ConnStr=
Driver=Microsoft Visual Foxpro Driver; UID=userID;SourceType=DBC;SourceDB=C:\yanhang\database
dbc
Conn
Open ConnStr
%>
Oracle數據庫連接
<%
set conn=server
createobject(
nnection
)
conn
cursorlocation=adUseClient
DSNTemp=
Provider=MSDAORA
;Password=xxxxx;User ID=yanhang;Data Source=xxx
world
conn
open DSNtemp
%>
From:http://tw.wingwit.com/Article/program/Java/hx/201311/26239.html