Wrox Programmer Forums
|
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
 
Old October 6th, 2007, 11:36 AM
Registered User
 
Join Date: Oct 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default table query

I need to make a html table where one of the fields will have a one-to-many relationship.

currently, this field's data is written every time in the loop:

1 - 1
1 - 2
1 - 3
1 - 4

2 - 1
2 - 2
2 - 3
...

what I want is something more like:

1 - 1
  - 2
  - 3
  - 4

2 - 1
  - 2
  - 3
  - 4

...

I just haven't got enough asp experience to solve this problem, nor the time to mess about :|.

 
Old October 6th, 2007, 05:43 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Just use a loop. Here is the psuedo code. (BTW, I am not going to write fully functional code for you, I understand that you don't have enough experience with ASP to figure this out on your own, and that is ok, but I refuse to simply do some ones work for them. This will be enough to get you started.)

Your asp code would potentially look like this:
Code:
<%
'Populate a record set
%>
<table>
<%
  Dim id
  id = 0
  do while not rs.eof
   If(id <> rs("id") Then
     id = rs("id")
%>
<tr><td><%=id%></td><td><%=rs("secondvalue")%></td></tr>
<%
   else
%>
<tr><td>-</td><td><%=rs("secondvalue")%></td></tr>
<%
   End If
  loop
%>
</table>
hth.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for:
Beginning Visual C# 2008
Professional Search Engine Optimization with ASP.NET
Professional IIS 7 and ASP.NET Integrated Programming
Wrox Blox: Introduction to Google Gears
Wrox Blox: Create Amazing Custom User Interfaces with WPF and .NET 3.0
================================================== =========
 
Old October 6th, 2007, 10:58 PM
Registered User
 
Join Date: Oct 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi,
thanks for the suggestion. actually sat down and decided to 'figure it out' right after posting here.

came up with something similar to what you suggested. used a loop and inside the loop an IF ... ELSE conditional statement.

dunno if that's the way to go about it though, felt like I 'cheated'...
I had initially thought I might be able to set up two recordsets, one with just the one field (the one in one-to-many) and the other recordset an amalgamation of both tables. then just loop the 'one rs' until eof, whilst passing the field as a variable to compare on the other rs and looping that within the loop... yeah sounds convoluted and problematic, turned out I just didn't have the patience to even attempt my 'proper' solution and did the 'cheat' thing with IF ELSE.

anyway, it's reassuring to know that there are people here who will read and respond, helpfully.


btw, since I'm just getting into all this, would I be better off learning ASP.NET now, rather than "classic ASP"?

I feel I learn more, when looking at and hacking away through 'code', and the MS development environment for .NET is awfully complicated and cumbersome to my mind but, if that's the future... I should better use my time towards acquiring that skill?

 
Old October 7th, 2007, 01:08 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

You could set up 2 recordsets, sure, but that would be less optimal and the long way around to accomplish what you want to do.

Anyway, in so far as ASP vs. ASP.NET it depends. I am an old school ASP guy myself that switched over to .NET when the 1.1 framework was released. You may feel that the IDE's (Visual Web Developer, Visual Studio, etc) are cumbersome but it removes alot of the cumbersome code you had to write in Classic ASP. Is it the future, I would say yes to that but that is not to say that ASP is completely dead.

Agencies still rely on Legacy ASP application to provide X functions (take this forum for example, it is still running on ASP) I wouldn't discourage you from learning ASP but, as soon as you get the chance, get your feet wet with .NET.

hth.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for:
Beginning Visual C# 2008
Professional Search Engine Optimization with ASP.NET
Professional IIS 7 and ASP.NET Integrated Programming
Wrox Blox: Introduction to Google Gears
Wrox Blox: Create Amazing Custom User Interfaces with WPF and .NET 3.0
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
Which query uses that table? d-fxt Access 3 November 17th, 2006 08:24 AM
Query Table NEED HELP royaloba Pro VB 6 1 October 18th, 2006 11:56 AM
Can a Make Table Query produce a Linked table? kronik Access 5 May 16th, 2006 06:17 AM
Make Table query : table in Another Database marnik Access 1 March 19th, 2005 12:39 PM
Error on Make-Table Query In Union Query rylemer Access 1 August 20th, 2003 07:42 PM





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