Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connect to Access from ASP 101

Status
Not open for further replies.

LonnieJohnson

Programmer
Apr 16, 2001
2,628
US
Hello all.

I had one of those 8 hour classes which is nothing. I am an Access/VBA programmer. I am wanting to just do the basics (I mean basics). I have an html page that calls an asp page. In the asp page I just want to show the records in an Access table. There are three fields ID, LName, FName.

Can any one give me the basic, novice, Jr ASP code to do this?

Thanks. prodevmg@yahoo.com
ProDev, MS Access Applications B-)
May God bless you in the year 2002.
 
<%Response.AddHeader &quot;Content-Language&quot;, &quot;VBscript&quot;%>
'this is a dsn-less connection example
<HTML>
<HEAD><TITLE>show DB records</TITLE></HEAD>
<BODY>
<%
Dim ObjConn
Dim rs
Dim strConn
Set ObjConn = Server.CreateObject(&quot;ADODB.Connection&quot;)
strConn=&quot;Driver=Microsoft Access Driver (*.mdb); DBQ=&quot; & server.mappath(&quot;/db.mdb&quot;)& &quot;;&quot;
ObjConn.Open strConn
Set rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)

rs.Open &quot;SELECT * FROM table&quot;, ObjConn
%>
<%
Response.Write(&quot;<CENTER>&quot;)
Response.Write(&quot;<TABLE BORDER=3 bgcolor=lightblue>&quot;)
Do while not rs.EOF
Response.Write(&quot;<TR>&quot;)
for x=0 to rs.Fields.count-1
Response.Write(&quot;<TD>&quot;)
Response.Write(rs(x))
Response.Write(&quot;</TD>&quot;)

next
'so we populate all the records
Response.Write(&quot;</TR>&quot;)
rs.MoveNext

Loop
Response.Write(&quot;</TABLE>&quot;)
%>
<%
'close the database and set connection to nothing
ObjConn.Close
Set rs=Nothing
Set ObjConn=Nothing
%>
</BODY>
</HTML> [bomb]
I may not get it the 1st or 2nd time,
but how sweet that 15th time can be.
admin@onpntwebdesigns.com
 
Turkbear,
This is a great resource. I bookmarked it as a favorite.

onpnt,
Thanks for the detail. That's what I needed.

Thanks guys. If you ever need anything on the Access/VBA side. Don't hesitate to ask.

prodevmg@yahoo.com
ProDev, MS Access Applications B-)
May God bless you in the year 2002.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top