Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #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
%>

Reply With Quote
  #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


Reply With Quote
  #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>")
Reply With Quote
  #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

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 01:52 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.