Beginner question: SQL results into tables.
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.
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.
Re: Beginner question: SQL results into tables.
Seems like you are using VB, and the concatenation character for VB is '&' not '+'
|All times are GMT +5.5. The time now is 06:06.|