probably easy for you, but . . .

Discussion in 'ASP General' started by middletree, Jul 28, 2003.

  1. middletree

    middletree Guest

    Over the years, believe it or not, I have never used Multiple select boxes.
    Now, can someone tell me where I can see some sample code for how to get
    data from there and use it? Specifically, the select box will list the first
    and last names of employees (this is Intranet), and I want to take the
    employee ID (which would be the value of each selection) and use it on the
    next page to go back into the employee table of the database and pull up
    their email address, send emails using CDO, store the fact that an email was
    sent into the database, etc.

    I do better with sample code than philosophical explanations.

    thanks
    middletree, Jul 28, 2003
    #1
    1. Advertising

  2. A multiple select box gives a comma-separated list of chosen values. So
    something as simple as:

    sql = "SELECT * FROM table WHERE employeeID IN (" &
    request.form("employeeID") & ")"

    Now, it would be more complicated if these were strings, because you'd have
    to insert delimiters. And don't forget earlier discussions about preventing
    SQL injection...

    A


    "middletree" <> wrote in message
    news:...
    > Over the years, believe it or not, I have never used Multiple select

    boxes.
    > Now, can someone tell me where I can see some sample code for how to get
    > data from there and use it? Specifically, the select box will list the

    first
    > and last names of employees (this is Intranet), and I want to take the
    > employee ID (which would be the value of each selection) and use it on the
    > next page to go back into the employee table of the database and pull up
    > their email address, send emails using CDO, store the fact that an email

    was
    > sent into the database, etc.
    >
    > I do better with sample code than philosophical explanations.
    >
    > thanks
    >
    >
    Aaron Bertrand - MVP, Jul 28, 2003
    #2
    1. Advertising

  3. > Ok, so if a user selects two people from the list, and the values are 100
    > and 200, then the Select statement would be
    >
    > sql = "SELECT * FROM table WHERE employeeID IN ("100,200")"


    Well, close... the embedded quotes wouldn't be there.

    > And then I would have to find a way to grab the email address (or whatever
    > info I need) from that table for both employee 100 and employee 200. Can

    you
    > guide me on this? This is the part about which I am most confused.


    sql = "SELECT employeeID, emailAddress FROM table WHERE employeeID IN (100,
    200)"
    set rs = conn.execute(sql)
    do while not rs.eof
    response.write "EmployeeID " & rs(0) & " e-mail:"
    response.write rs(1) & "<br>"
    rs.movenext
    loop
    Aaron Bertrand - MVP, Jul 28, 2003
    #3
  4. middletree

    middletree Guest

    OK, that makes sense. I appreciate it!


    "Aaron Bertrand - MVP" <> wrote in message
    news:eGYVV$...
    > > Ok, so if a user selects two people from the list, and the values are

    100
    > > and 200, then the Select statement would be
    > >
    > > sql = "SELECT * FROM table WHERE employeeID IN ("100,200")"

    >
    > Well, close... the embedded quotes wouldn't be there.
    >
    > > And then I would have to find a way to grab the email address (or

    whatever
    > > info I need) from that table for both employee 100 and employee 200. Can

    > you
    > > guide me on this? This is the part about which I am most confused.

    >
    > sql = "SELECT employeeID, emailAddress FROM table WHERE employeeID IN

    (100,
    > 200)"
    > set rs = conn.execute(sql)
    > do while not rs.eof
    > response.write "EmployeeID " & rs(0) & " e-mail:"
    > response.write rs(1) & "<br>"
    > rs.movenext
    > loop
    >
    >
    middletree, Jul 28, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rob Meade
    Replies:
    3
    Views:
    2,337
    Cowboy \(Gregory A. Beamer\)
    Nov 25, 2003
  2. Replies:
    6
    Views:
    327
    Rolf Magnus
    May 27, 2006
  3. Zerex71
    Replies:
    19
    Views:
    561
    Patricia Shanahan
    Aug 30, 2007
  4. Eric
    Replies:
    4
    Views:
    184
    Ray at
    Sep 24, 2003
  5. Tom Cloyd
    Replies:
    6
    Views:
    176
    Tom Cloyd
    Sep 3, 2009
Loading...

Share This Page