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
%>