Beginner question: SQL results into tables.

Discussion in 'ASP' started by Daseal, Apr 19, 2008.

  1. Daseal

    Daseal New Member

    Apr 19, 2008
    Likes Received:
    Trophy Points:
    Hello everyone,

    I'm relatively new to and Ive been stuck on something for about a day now and couldn't find much of an answer anywhere so I'm hoping a forum might help.

    I'm working on an asp page that has a drop down menu, when you hit Submit, gridView and a label pops up. Then it should query the database, match up the value of their selection with the "ID" label in my database, and return the results. Everything works great except for one issue. I can't seem to send the value from the selection to the Select statement.

    For example:
    SelectCommand="SELECT Number, Name, Date FROM table1 WHERE ID = 4 ORDER BY Number"

    This command works great when I toss the "Where ID = 4" in. However, I want the user selection to determine what 4 really is. I've tried to work "DropDownList1.SelectedItem.Value" every way I could think of, but could never get it to work. After browsing the internet I saw a few things about having a database load the values into the drop down list, and it seemed far over my head as a beginner. Is there a simple fix to plug in the selectedItem.Value, or something else similar?

    In the aspx.vb section of the page I was also able to type up exactly what I wanted and didnt get any errors:

    Dim query As String
    query = "SELECT Number, Name, Date FROM table1 WHERE ID=" + DropDownList1.SelectedItem.Value + " ORDER BY Number"

    Any help would be appreciated! Thanks in advance.
  2. pradeep

    pradeep Team Leader

    Apr 4, 2005
    Likes Received:
    Trophy Points:
    Kolkata, India
    Home Page:
    Seems like you are using VB, and the concatenation character for VB is '&' not '+'

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice