473,794 Members | 2,754 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1460
"JP SIngh" <no**@none.co m> wrote in message
news:OC******** ******@TK2MSFTN GP12.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.co m> wrote in message
news:OC******** ******@TK2MSFTN GP12.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
1871
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 an Access 2000 table like this: QUESTION_NUMBER QUESTION 1 Question 1 text.... 2 Question 2 text....
7
1259
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
5056
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);"); body.Attributes.Add("onKeyUp", "highlight(event);"); Some of my forms have a great many text box controls that I want to highlight.. I would much rather that ASP.NET do the work of looping through all text boxes and applying these two attributes.
16
1458
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 provide feedback. To participate you would... 1. Sign a non-disclosure agreement 2. Read each chapter in Word format and mark it up and return it within a week of receipt 3. Be open honest and direct, providing feedback about the content and...
7
1861
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 forms in an application to find out something, such as if a particular form it loaded, or how many of a particular type of form are loaded. Windows Forms does not include a Forms collection, however, so gaining such functionality in Visual Basic...
13
3037
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 for accessing objects, controls, etc. in VB/Access2003. In particular where will I find explanations of:- Actions, Functions, Methods, Properties - I'm understand the
20
2853
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 then
2
2083
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 buttonStart_Click(System::Object^ sender, System::EventArgs^ e){ for (int i=1; i<=10; i++){ String^ strValue; FunctionName(&strValue); int interval=1000; // time...
2
1397
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 first and moving on to the next answer. Here's the code: <html><head><title>Problem7</title>
3
1953
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 and question2 is selected this code is working fine. But if None of answer of either question selected, it is not iterating through outer loop. Please help me to point out the error. <html> <head> <style type="text/css"> body...
0
9671
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9518
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10212
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6777
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5560
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3720
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.