Home >Database >Mysql Tutorial >ADO连接Access的几种规范做法

ADO连接Access的几种规范做法

WBOY
WBOYOriginal
2016-06-07 14:56:221285browse

ADO连接Access的几种规范做法: ADO数据对象用来连接数据库的方式有两种,分别是ODBC和OLE DB方式 (一) 使用OLE DB方式 ******************************************************** *** OLE DB Provider for Microsoft Jet *******************************

  ADO连接Access的几种规范做法:

  ADO数据对象用来连接数据库的方式有两种,分别是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数据库

  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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn