473,382 Members | 1,407 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Basic Looping Question

Hi All

I have threee tables like the one below and i would like to ask if it is
possible to display the data from all three tables using a single recordset
in ASP.

TABLE - tblList

id - Number
ListName - Text

TABLE - tblListMembers

ListId - Number
Username - Text

TABLE - tblEmployees

UserName - Text
FirstName - Text
LastName - Text
Email - Text

This is to store data like Distribution lists in outlook.

What I want to display on one page is to display all the list and the name
of the members? but the poor code opens two records sets and is very slow

This is what I am doing at the moment. (not exact code but just a general
idea)

SQL = "Select Id, Listname from tblListMembers"
RS.Open SQL,conn
Do while not rs.eof
Response.write "Listname" & "<br>"
stSQL = "Select * from tblListMembers where listid = " & rs("id")
rs1.open stSQL, conn
Do while not RS1.eof
Response.write "- --- -- " & rs("username") & "<br>"
rs1.movenext
loop
rs1.close
rs.movenext
loop
I am certain opening a record set within a loop continuously is a bad
practice. Can someone please let me know how can I get this information in
single recordset and how can I display that.

Many thanks
Jas
Aug 3 '05 #1
2 1443
"JP SIngh" <no**@none.com> wrote in message
news:OC**************@TK2MSFTNGP12.phx.gbl...
I have threee tables like the one below and i would like to ask if it is
possible to display the data from all three tables using a single recordset in ASP.
<snip>
What I want to display on one page is to display all the list and the name
of the members?


the query :

select t.ListName
, e.Username, e.Firstname, e.LastName, e.Email
from tblList t
, tlbListMembers lm
, tblEmployees e
where t.id = lm.ListId
and lm.Username = e.Username
order by t.Listname, e.LastName, e.Firstname

the skeleton code :

rs.MoveFirst
Do While Not rs.EOF
sPrevList = rs("ListName")
' Generate List "heading" and start member list
Do While Not rs.EOF And rs("ListName") = sPrevList
' generate member entry
rs.MoveNext
Loop
' Close List section
Loop

HTH,
Phill W.
Aug 3 '05 #2
CJM

"JP SIngh" <no**@none.com> wrote in message
news:OC**************@TK2MSFTNGP12.phx.gbl...
Hi All

I have threee tables like the one below and i would like to ask if it is
possible to display the data from all three tables using a single
recordset
in ASP.

It is possible. You can UNION similar groups of records to produce a larger
recordset, and you can JOIN tables together and query them via their
relationships. It looks like you will need to query these tables using a
Join.
TABLE - tblList

id - Number
ListName - Text

TABLE - tblListMembers

ListId - Number
Username - Text

TABLE - tblEmployees

UserName - Text
FirstName - Text
LastName - Text
Email - Text

This is to store data like Distribution lists in outlook.

What I want to display on one page is to display all the list and the name
of the members? but the poor code opens two records sets and is very slow

In the 3 mins I have spent looking at this, it wasn't clear exactly what you
are trying to do. Can you explain in some more detail?
This is what I am doing at the moment. (not exact code but just a general
idea)

SQL = "Select Id, Listname from tblListMembers"
RS.Open SQL,conn
Do while not rs.eof
Response.write "Listname" & "<br>"
stSQL = "Select * from tblListMembers where listid = " & rs("id")
rs1.open stSQL, conn
Do while not RS1.eof
Response.write "- --- -- " & rs("username") & "<br>"
rs1.movenext
loop
rs1.close
rs.movenext
loop
I am certain opening a record set within a loop continuously is a bad
practice. Can someone please let me know how can I get this information in
single recordset and how can I display that.


You right that this isn't the best way to go about it.

See: http://www.aspfaq.com/show.asp?id=2241

When we have a better idea about what you are trying to achieve, we'll be
able to help build better code..

Chris
Aug 3 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Colin Steadman | last post by:
I've create a simple survey using ASP. Its finished and works, but one aspect of my coding is annoying me and I cant figure out a better way of doing it. Basically the questions are stored in...
7
by: Paolo Pignatelli | last post by:
I have the following XML file: -------------- <?xml version="1.0" encoding="ISO-8859-1" ?> <?xml-stylesheet type="text/xsl" href="sample2.xslt"?> <Employees> <Employee>
4
by: | last post by:
I have a "form field highlight" javascript that I've added to some of my ASP.NET forms using the following syntax: body.Attributes.Add("onClick", "highlight(event);");...
16
by: Jesse Liberty | last post by:
I am writing a new book on Visual Basic 2005, targeted at VB6 programmers, and to some degree VB.NET 1.x programmers. I'd like to sign up a (limited) number of volunteers to read the book and...
7
by: gerryLowry::Ability Business Computer Services {KC | last post by:
"Getting Back Your Visual Basic 6.0 Goodies" by Billy Hollis, 2003-5-14, states: "Getting a Forms Collection Visual Basic 6.0 developers are often fond of looping through the currently loaded...
13
by: usenet | last post by:
How and where can one find out about the basics of VB/Access2003 syntax? I am a died in the wool C/C++/Java Linux/Unix programmer and I am finding it difficult to understand the program format...
20
by: Ifoel | last post by:
Hi all, Sorry im beginer in vb. I want making programm looping character or number. Just say i have numbers from 100 to 10000. just sample: Private Sub Timer1_Timer() if check1.value= 1...
2
by: Davaa | last post by:
Dear all, I am a student making a MS Form application in C++. I would ask a question about "Timer". Sample code which I am developing is below. private: System::Void...
2
by: LayneMitch via WebmasterKB.com | last post by:
Hello. This is a basic quiz. Only about 3 questions. I'm having issue with the answer key which stays on a certain value regardless of acknowledging that you have the correct answer for the...
3
by: chiku1523 | last post by:
Hi, Please find the following code. In function setAnswers, I am looping with each question. I have inner loop, which is looping for each answers of the questions. If any of the answer for question...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.