How to display table from Microsoft Access to ASP file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • puT3
    New Member
    • Jul 2008
    • 145

    How to display table from Microsoft Access to ASP file

    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
    Recognized Expert New Member
    • Oct 2008
    • 228

    #2
    Originally posted by puT3
    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' "

    Code:
    Sub DrawTable(ByRef thers, ByVal params)
    
    If Not left(params,1) = " " then params = " " & params
    
    thers.movefirst
    Response.Write "<table" & params & ">"
    Response.Write "<tr>"
    For Each header in thers.Fields
    Response.Write "<th>" & header.Name & "</th>" & vbNewLine
    Next
    Response.Write "</tr>" & vbNewLine
    Do While Not thers.eof
    	Response.Write "<tr>"
    		For Each Field in thers.Fields
    			Response.Write "<td>" & Field & "</td>"
    		Next
    	Response.Write vbNewLine & "</tr>" & vbNewLine
    	thers.movenext
    Loop
    Response.Write "</table>"
    End Sub
    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.

    Comment

    Working...