#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2004
    Posts
    70
    Rep Power
    29

    Assistance with While Loop


    I have these fields in a database:
    userid, empname, duedate, currentstep, managerid, managername, manageremail
    I need to take each userid group them by managerid and send that manager an email with all of the columns.

    So in my SqlDataAccessLayer I have: SelectUniqueManager
    To find all of the unique managerid.

    ("SELECT DISTINCT[managerid] FROM[dbo].[Orientation] ORDER BY [managerid] "
    Then I have: SelectAllUnderManager

    To pull all of the data for each of those managers.
    ("SELECT * FROM [Orientation] ORDER BY [managerid], [userid] WHERE [managerid]= @managerID"

    Thank you.
  2. #2
  3. Impoverished Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,825
    Rep Power
    9646
    It would be better to do one single query to get all the data, then use a little bit of logic in your code to figure out which users go to which manager.

    Use your second query but without the WHERE
    Code:
    SELECT * FROM [Orientation] ORDER BY [managerid], [userid]
    then...

    Well, from here on you'll have to post your code.

IMN logo majestic logo threadwatch logo seochat tools logo