Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old July 23rd, 2003, 05:59 AM
Registered User
 
Join Date: Jul 2003
Location: Cleethorpes, North East Lincolnshire, United Kingdom.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Tables

Can anyone tell me how to put each field of information into a separate cell in a table. I can put all the information in a table containing one row and one cell but I don't want that. I want a row and several cells for each record.
Hopefully this makes sense.
The code is below:

<%
  Dim objRS, objComm, objParam, strType
  Set objComm = Server.Createobject("ADODB.Command")

  objComm.ActiveConnection = strConnect
  objComm.CommandText = "qryMainsDrills"
  objComm.CommandType = adCmdStoredProc

  Set objParam = _
     objComm.CreateParameter("Required Type", adVarChar, adParamInput, 50)
  objComm.Parameters.Append objParam

  strType = "Mains"
  objComm.Parameters("Required Type") = strType

  Set objRS = objComm.Execute

  Set objComm = Nothing
  Set objParam = Nothing


  While Not objRS.EOF
    Response.Write objRS("ProductID") & " " & objRS("Manufacturer") & " " & objRs("ProductDescription") & " " & objRS("ProductCode") & " " & objRS("UnitPrice") & "<BR>"
    objRS.MoveNext
  Wend

  objRS.Close
  Set objRS = Nothing
%>

  #2 (permalink)  
Old July 23rd, 2003, 06:10 AM
Authorized User
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default


Hi
 there are various ways to achieve this, but try the following for starters....


If Not objRS.EOF And Not objRS.BOF Then
  Response.Write "<table width=""100%"" cellpadding=""2"" cellspacing=""2"" border=""1"" >"
 'start looping...
 While Not objRS.EOF
    Response.Write "<tr>"
    Response.Write "<td>" & objRS("ProductID") & "</td>"
    Response.Write "<td>" & objRS("Manufacturer") & "</td>"
    Response.Write "<td>" & objRs("ProductDescription") & "</td>"
    Response.Write "<td>" & objRS("ProductCode") & "</td>"
    Response.Write "<td>" & objRS("UnitPrice") & "</td>"
    Response.Write "</tr>"
    objRS.MoveNext
  Wend
  Response.Write "</table>"
Else
Response.Write "No data!
"
End If


  #3 (permalink)  
Old July 23rd, 2003, 06:17 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Just change your loop to write out HTML tags like this:
Code:
' create table and column headers
Response.Write("<table>")
Response.Write("<tr><td>ProductID</td><td>Manufacturer</td>etc...</tr>")
While Not objRS.EOF
    ' create a new row for each record
    Response.Write("<tr>")

    ' put each field value inside a <td>
    Response.Write("<td>")
    Response.Write objRS("ProductID")
    Response.Write("</td>")
    Response.Write("<td>")
    Response.Write objRS("Manufacturer")
    Response.Write("</td>")
    ' ... etc

    ' close the row
    Response.Write("</tr>")

    objRS.MoveNext
  Wend

' close the table
Response.Write("</table>")
  #4 (permalink)  
Old July 23rd, 2003, 11:09 AM
Registered User
 
Join Date: Jul 2003
Location: Cleethorpes, North East Lincolnshire, United Kingdom.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your help, everything is sorted now.
Cheers



Similar Threads
Thread Thread Starter Forum Replies Last Post
creating tables within tables in access??? carswelljr Access 3 August 23rd, 2006 01:21 PM
Fixed tables and/or fixed bkgrnd in tables slg111875 Dreamweaver (all versions) 1 June 22nd, 2006 02:31 PM
Tables mistry_bhavin ADO.NET 2 May 4th, 2004 09:16 AM
Regarding Tables spraveens HTML Code Clinic 2 October 20th, 2003 04:46 AM
regarding tables spraveens Dreamweaver (all versions) 1 September 24th, 2003 07:21 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.