selecting from a table and listing various data from another one related to the first

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Jan 2009
Posts: 12
Reputation: mr.white is an unknown quantity at this point 
Solved Threads: 0
mr.white mr.white is offline Offline
Newbie Poster

selecting from a table and listing various data from another one related to the first

 
0
  #1
Jan 8th, 2009
Hello,

I'm making a phone book application. I store general information of people such as name etc on one table called "people", and I've another table called "relatedInformation" which has 5 columns (ID, Name, Info, PersonID, Type). In this table I store all other information regarding people, because a person might have more than one address, phone number or email.

So let's say there is I got one row data from People table with SqlDataReader, and print the "Name" value on the screen.

Now what I want is, I want to do another query to "relatedInformation" table, select data where Type is 1 (phone numbers), and PersonID is the ID from "People" table. so I can list all phone numbers.

Then another query but this time select the ones where Type is 2 (addresses, for example.)

what is the logic behind doing this with C# and ASP.NET ?

if I create data command and then a data reader and stuff for each one of these things, code becomes really heavy.
In old ASP it only took 2 lines of code to do this with using RecordSet.

Can you please explain me the logic of doing this and, if possible help me with some code?
And if i couldn't make my self clear, please ask me so I can explain more clearly.

Thank you very much.
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 178
Reputation: Kusno is an unknown quantity at this point 
Solved Threads: 14
Kusno's Avatar
Kusno Kusno is offline Offline
Junior Poster

Re: selecting from a table and listing various data from another one related to the first

 
0
  #2
Jan 8th, 2009
I think you need to use 3 SQLConnections, SQLCommands and SQLDataReader.

first, to read People
second, to read relatedInformation
and the last is to read Type

Thanks.
NEVER NEVER NEVER GIVE UP
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the ASP.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC