1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Beginner question: SQL results into tables.

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

  1. Daseal

    Daseal New Member

    Joined:
    Apr 19, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hello everyone,

    I'm relatively new to asp.net 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

    Joined:
    Apr 4, 2005
    Messages:
    1,646
    Likes Received:
    86
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    Seems like you are using VB, and the concatenation character for VB is '&' not '+'
     

Share This Page