Select list item thenQuery Database with generic query?
Posted on 2005-05-05
I have a listbox with my stock#'s. I have a query string to SQL that can pull the data I need.
My question is how could I select a stock# on the list and automatically proform a query for the selected stock# details to return the year, make, model etc to some labels on my form.
Heres what I have so far for a connection and query...
Dim conn As New SqlConnection("My connection string;")
Dim cmd As New SqlCommand
Dim dr As SqlDataReader
cmd.Connection = conn
cmd.CommandType = CommandType.Text
cmd.CommandText = "SELECT StockNumber,Year,Make,Model,Color, Miles FROM dbo.VehicleMaster ORDER BY StockNumber"
dr = cmd.ExecuteReader
Catch ex As SqlException