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=d:\\database\\db.mdb"
conn.Open Strconn
%>

用实际的数据库相对路径连接:
<%
Set conn = Server.CreateObject("ADODB.Connection")
Strconn="DRIVER={Microsoft Access Driver (*.mdb)}; "
Strconn=Strconn & "DBQ=" & Server.MapPath("/database/db.mdb")
conn.Open Strconn
%>

<%
set conn=server.CreateObject("adodb.connection")
set rs=server.CreateObject("adodb.recordset")
constr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("/database/db.mdb")
conn.open constr
%>

posted on 2009-01-24 10:03  Jacky Yu  阅读(184)  评论(0编辑  收藏  举报