ADO連接Access的幾種規(guī)范做法:
ADO數(shù)據(jù)對(duì)象用來(lái)連接數(shù)據(jù)庫(kù)的方式有兩種,分別是ODBC和OLE DB方式
(一) 使用OLE DB方式
********************************************************
*** OLE DB Provider for Microsoft Jet
********************************************************
Dim oConn,strConn
Set oConn=Server.CreateObject("ADODB.Connection")
StrConn= "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:somepathmyDb.mdb;" & _
"User Id=admin;" & _
"Password=;"
oConn.Open strConn
********************************************************
*** OLE DB Provider for ODBC Databases
********************************************************
訪問MS Access數(shù)據(jù)庫(kù)
Dim oConn,strConn
Set oConn=Server.CreateObject("ADODB.Connection")
StrConn= "Provider=MSDASQL;" & _
"Driver={Microsoft Access Driver (*.mdb)};" & _
"Dbq=c:somepathmydb.mdb;" & _
"Uid=myUsername;" & _
"Pwd=myPassword;"
oConn.Open strConn
(二) 使用ODBC方式
********************************************************
*** ODBC Driver for Access
********************************************************
Dim oConn,strConn
Set oConn=Server.CreateObject("ADODB.Connection")
StrConn= "Driver={Microsoft Access Driver (*.mdb)};" & _
"Dbq="&Server.MapPath("Testdb.mdb"); & _
"Uid=AdminAccount;" & _
"Pwd=Password;"
oConn.Open strConn
更多信息請(qǐng)查看IT技術(shù)專欄