Displaying records from an Access 97 table

Results 1 to 2 of 2

Thread: Displaying records from an Access 97 table

  1. #1
    Join Date
    Dec 1969

    Default Displaying records from an Access 97 table

    I&#039m fairly new to the world of ASP so please bear with me. I want to display the records from my Access 97 database table on my web page. My table and DSN are both named tblPetition. <BR><BR>I am able to successfully write new data to the table but now I want to display the records in there but haven&#039t figured out to do this part of it. <BR><BR>Any advice is greatly appreciated!<BR><BR>Brian

  2. #2
    keithadler@hotmail.com Guest

    Default RE: Displaying records from an Access 97 table

    There&#039s many ways to do what you&#039re trying to do. The easiest is to use a Recordset DTC and a Grid DTC (if you&#039re using Visual InterDev). The other option is to create an ASP page and to put the following code into it:<BR><BR><BR>&#060;%<BR> <BR> &#039 Variables<BR> <BR> Dim cnConnection<BR> Dim objField<BR> Dim rsRecordset<BR> Dim strSQL<BR> <BR> &#039 Create the connection and recordset objects<BR> <BR> Set cnConnection = Server.CreateObject("ADODB.Connection")<BR> Set rsRecordset = Server.CreateObject("ADODB.Recordset")<BR> <BR> &#039 What table data are you accessing from you data source<BR> <BR> strSQL="Your Table Name Goes Here"<BR> <BR> &#039 Open the connection<BR> <BR> cnConnection.Open "DSN=tblPetition"<BR> <BR> With rsRecordset<BR> <BR> &#039 Populate our recordset object<BR> <BR> .Open strSQL,cnConnection<BR> <BR> If Not .EOF Then<BR> <BR> &#039 Setup the table<BR> <BR> Response.Write "&#060;TABLE Border=1&#062;"<BR> <BR> &#039 More through and write out the data<BR> <BR> Do Until .EOF<BR> <BR> &#039 Start the line<BR> <BR> Response.Write "&#060;TR&#062;"<BR> <BR> &#039 Write out each field<BR> <BR> For Each objField In .Fields<BR> <BR> Response.Write "&#060;TD&#062;" & objField.Value & "&#060;/TD&#062;"<BR> <BR> Next<BR> <BR> &#039 Finish the line<BR> <BR> Response.Write "&#060;/TR&#062;" & vbNewLine<BR> <BR> .MoveNext<BR> <BR> Loop<BR> <BR> &#039 Close the table<BR> <BR> Response.Write "&#060;/TABLE&#062;"<BR> <BR> End If<BR> <BR> &#039 Close our recordset<BR> <BR> .Close<BR> <BR> End With<BR> <BR> &#039 Close our connection<BR> <BR> cnConnection.Close<BR> <BR> &#039 Clean things up<BR> <BR> Set rsRecordset=Nothing<BR> Set cnConnection=Nothing<BR> <BR>%&#062;<BR><BR>With this code you can do an endless amount of possible HTML formatting. You could also easily alternate the color of the rows.<BR><BR>I hope this helps.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts