Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


New to asp.net

 
Logged in as: Guest
arrSession:exec spGetSession 2,4,35210
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> ASP.NET >> New to asp.net
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 New to asp.net - 6/7/2006 8:06:02 AM   
  yushyush

 

Posts: 10
Score: 0
Joined: 2/12/2006
Status: offline
Well, i'm new to asp.net, and now i'm stuck ..

My main problem is that i need to select data from few tables using their relationships as defined in database.
Let's presume i've got 2 tables, tblUsers, and tblAddress
tblUsers fields: userId, userName
tblAddress: adrrId, userId, addressStr
it has 1:N relationship -

basicly, i want to select few rows from tblUsers :
"SELECT * FROM tblUsers WHERE userName='pirate'"
then i fill dataset.tblUsers with the results.

I've got more then 1 user from tblUsers, and i allready have a pre-defined dataset with the proper relations defined.

Now, i need to only the relevant rows from tblAddress. Meaning that i don't want entries from tblAddress where userId is not one of the userId's returned by the previous query..

Is there any reasonable, non complex way to do so?
My current options are:
1. Loop over dataset.tblUsers and performing 'n' select queries: "SELECT * FROM tblAddress WHERE userId =" + dataSet.tblUsers.rows... (if i recall correctly), then joining them up together in one dataTable
2. Using IN operator with select inside a select: "SELECT * from tblAddress WHERE userId IN (SELECT userId from tblUsers)"
3. Pulling all the data, with the irelevant one aswell. then using relations to filter out the irelevant data on code-behind  level.

All options seem to be rather bad for me, since they eat up alot of unneccesarry system resources (the database is rather big)
While the 1 and 2 seem to have  N*N complexity, the 3rd seem to be passing alot of irelevant data...
Is there any shortcut? any using relations inside the database?

Please help ..

Thanks in advance :)
 
 
Post #: 1
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> ASP.NET >> New to asp.net Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts