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

    Join Date
    May 2004
    Rep Power

    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. Headless Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Washington, USA
    Rep Power
    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
    SELECT * FROM [Orientation] ORDER BY [managerid], [userid]

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

IMN logo majestic logo threadwatch logo seochat tools logo