New to asp.net

Author Message
yushyush

  • Total Posts : 10
  • Scores: 0
  • Reward points : 0
  • Joined: 2/12/2006
  • Status: offline
New to asp.net Wednesday, June 07, 2006 9:06 AM (permalink)
0
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 :)
 
#1

    Online Bookmarks Sharing: Share/Bookmark

    Jump to:

    Current active users

    There are 0 members and 1 guests.

    Icon Legend and Permission

    • 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
    • Read Message
    • Post New Thread
    • Reply to message
    • Post New Poll
    • Submit Vote
    • Post reward post
    • Delete my own posts
    • Delete my own threads
    • Rate post

    2000-2012 ASPPlayground.NET Forum Version 3.9