Join us on Facebook!
28
Feb

Simple Table Display (Select Fields)

by admin 151 views 0 Comments and 0 Rections

Displaying data from an Access or SQL Server database is easy to accomplish in .asp. The following example utilizes our Access database of Mark 'The Bird' Fidrych and selects specific season statistics contained in the database for display based upon what appears in the select statement in our sql query. A query utilizing select * will bring across every table element and if every element is not needed resource has been wasted. In addition select will not allow grouping function which may be critical for some applications.

 


CodeAve.com(Display Table with Select Fields(Hard-Coded))

<%
' Name of the Accessdb being read
accessdb="fidrych"

' Connect to the db with a DSN-less connection
cn="DRIVER={Microsoft Access Driver (*.mdb)};"
cn=cn & "DBQ=" & server.mappath(accessdb)

' Create a server recordset object
Set rs = Server.CreateObject("ADODB.Recordset")

' Select specific fields from the table the_bird
sql = "select year, team, w, l, cg, so, era from the_bird"

' Execute the sql
rs.Open sql, cn
%>













<%
' Move to the first record
rs.movefirst

' Start a loop that will end with the last record
do while not rs.eof
%>
















<%
' Move to the next record
rs.movenext
' Loop back to the do statement
loop %>
Year Team W L CG SO ERA

<%= rs("year") %>

<%= rs("team") %>

<%= rs("w") %>

<%= rs("l") %>

<%= rs("cg") %>

<%= rs("so") %>

<%= rs("era") %>





<%
' Close and set the recordset to nothing
rs.close
set rs=nothing
%>
More Posts in "Tutorials"

Comments

blog comments powered by Disqus

Feed Subscription

Get daily inboxed with latest news, reviews and tutorials. Signup now it's free :)



Planetmaks on Twitter

Follow PlanetMaks on Facebook

Recent Comments

Powered by Disqus

Tags

32Bit 64Bit 7 Admin Tool Admin Tools Admin-Tool Admin-Tools AdminTool Adobe Adware All-in-One Anti-Spyware Anti-Virus Apple Backup Tools Browser Browsers Changing Default Directory Codec Data Recovery Download Manager Downloads Drive Utilities Driver Drivers Firefox Flash Freeware Google Graphics Internet Tool Internet-Tool Messaging Microsoft Microsoft Tool Micsellonous Monitoring Multimedia Networking News NVidia Office Tool Office-Tool PC Suite Press Release Registry Samsung Security Shareware Software Softwares Tutorials Vista Windows Windows 7 Windows 8