ASP连接Access数据库的方法如下:
Set conn = Server.CreateObject("ADODB.Connection")
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\mydatabase.mdb"
conn.Open
Set rs = conn.Execute("SELECT * FROM mytable")
rs.Close
conn.Close
完整示例代码:
<%
Dim conn, rs
Set conn = Server.CreateObject("ADODB.Connection")
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\mydatabase.mdb"
conn.Open
Set rs = conn.Execute("SELECT * FROM mytable")
While Not rs.EOF
Response.Write rs("field1") & " " & rs("field2") & "
"
rs.MoveNext
Wend
rs.Close
conn.Close
Set rs = Nothing
Set conn = Nothing
%>
辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读: ASP中如何创建和使用自定义函数库