Connecting Tech Pros Worldwide Forums | Help | Site Map

How to display table from Microsoft Access to ASP file

Member
 
Join Date: Jul 2008
Posts: 123
#1: Sep 9 '09
Hi,
I'm trying to make a dynamic website using asp and javascript and access as my database. I'm wondering if the asp file able to display table from access where user can view and change the information in the table...

GazMathias's Avatar
Expert
 
Join Date: Oct 2008
Location: Bristol, United Kingdom
Posts: 145
#2: Sep 9 '09

re: How to display table from Microsoft Access to ASP file


Quote:

Originally Posted by puT3 View Post

Hi,
I'm trying to make a dynamic website using asp and javascript and access as my database. I'm wondering if the asp file able to display table from access where user can view and change the information in the table...

What you are talking about is generally called Scaffolding. It is not a built in feature of classic ASP, but is available in some frameworks for other languages like Rails, PHP and ASP.Net.

That said, building one is something that I guess everyone does sooner or later in one way or form.

To get you started, simply draw out your table and include an edit link in each row, then send that row to somewhere you can edit it.

You must also take into consideration the design of the database with particular regard to data types, joins and referential integrity.

Just wrote a sub that draws out a recordset to get started, it takes two arguments:

thers = the name of a recordset you have opened.

params is properties for the table tag, ie "style = 'myTableStyle' "

Expand|Select|Wrap|Line Numbers
  1. Sub DrawTable(ByRef thers, ByVal params)
  2.  
  3. If Not left(params,1) = " " then params = " " & params
  4.  
  5. thers.movefirst
  6. Response.Write "<table" & params & ">"
  7. Response.Write "<tr>"
  8. For Each header in thers.Fields
  9. Response.Write "<th>" & header.Name & "</th>" & vbNewLine
  10. Next
  11. Response.Write "</tr>" & vbNewLine
  12. Do While Not thers.eof
  13.     Response.Write "<tr>"
  14.         For Each Field in thers.Fields
  15.             Response.Write "<td>" & Field & "</td>"
  16.         Next
  17.     Response.Write vbNewLine & "</tr>" & vbNewLine
  18.     thers.movenext
  19. Loop
  20. Response.Write "</table>"
  21. End Sub
  22.  
  23.  
I haven't yet looked into figuring out what the PK of the table is to provide the edit link, might do later if I get time.

Gaz.
Reply