Support
You must have a working knowledge of programming with Active Server Pages (ASP), designing Access databases and HTML to use this information. Web development is not part of free support, but we provide as much information as possible online to assist our customers with Development issues they face. Learn more about ASP at Fpweb.net's ASP Resources page.
For sake of understanding on how you modify the code below for your use, we will use the following:
First, there are two basic types of connections to an Access database – DSN and DSN–less.
DSN:
Dim conn
Set conn = Server.CreateObject("ADODB.Connection")
conn.ConnectionString = "DSN=mydsn"
conn.Open
DSN–less:
Dim conn
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & _
Server.MapPath("myfolder\mydatabase.mdb"))
(ASP 3.0 & VBScript)
Uses the DSN connection noted above.
To use the DSN–less connection noted above, substitute the DSN code with the DSN–less code. The ASP code begins with <% and ends with %>, which is required.
–––– code begins under this line of text ––––
<%@ Language=VBScript %>
<%
Dim conn
Set conn = Server.CreateObject("ADODB.Connection")
conn.ConnectionString = "DSN=mydsn"
conn.Open
Dim strSQL, rs
strSQL = "Select lastname from mytable"
set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strSQL, conn
Response.Write "<h1>Connection Works!</h1>"
Response.Write "<h2>Database Records Below</h2>"
do while not rs.EOF
Response.Write rs("lastname")
Response.Write "<BR>"
rs.MoveNext
loop
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing
%>
–––– code ends above this line of text ––––
Make I.T. easy for your business with fully managed dedicated hosting from Fpweb.net.