vb与access数据库连接有几种方法

兄弟姐妹哪位知道,vb与access数据库连接有几种方法
最新回答
猫小柒

2024-06-07 16:04:36

方法如下:
第一种连接和记录集分开声明
<%
db="db/darden.mdb"
set conn=server.createobject("ADODB.connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("" & db & "")
conn.open connstr
%>
<%
set rs=server.createobject("adodb.recordset")
sql="select * from ebook order by id desc"
rs.open sql,conn,3,3
rs.addnew
......
......
rs.update (rs.delete)
rs.close
set rs=nothing
conn.close
set conn=nothing
response.write("<center><a href=viewdatabase.asp>显示文字</a></center>")
Response.Redirect "homepage.asp"
%>
第二种连接和记录集一同声明
<%
set rs=server.createobject("adodb.recordset")
sql="select * from ebook order by id desc"
conn = "DBQ=" + server.mappath("book.mdb") + ";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
rs.open sql,conn,3,3
rs.addnew
......
......
rs.update (rs.delete)
rs.close
set rs=nothing
response.write("<center><a href=viewdatabase.asp>显示文字</a></center>")
%>
ASP数据库简单*作教程
<1>.数据库连接(用来单独编制连接文件conn.asp)
<%
Set conn = Server.CreateObject(ADODB.Connection)
conn.Open DRIVER={Microsoft Access Driver (*.mdb)}; DBQ= & Server.MapPath(\bbs\db1\user.mdb)
%>