I have 3 dropdown lists, catagory, name, model. Select catagory to enable name and model. select a name or a model and the coresponding name/model will autofill in the other dropdown based upon results of executeScalar. If i have the catagory "Cellular" it works fine with ALL my products. If I switch the catagory to anything else it stops working. The code is exactly the same.... i dont get it.
Try If Not ddlProductName.SelectedValue = "-Select Product-" Then Dim SelectQuery As String = _ "SELECT [PRODUCT_MODEL] FROM BHInventory.dbo.PRODUCT WHERE [PRODUCT_NAME] ='" + ddlProductName.SelectedValue + "'" Dim SQLConn As New SqlConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString")) SQLConn.Open() Dim SqlCom As New SqlCommand(SelectQuery, SQLConn) Dim RowCnt = SqlCom.ExecuteScalar() SQLConn.Close() SQLConn.Dispose() Dim res As String res = RowCnt.ToString ddlModelName.Items.FindByText(ddlModelName.SelectedValue.ToString).Selected = False ddlModelName.Items.FindByText(res).Selected = True Else ddlModelName.Items.FindByText(ddlModelName.SelectedValue.ToString).Selected = False ddlModelName.Items.FindByText("-Select Model Number-").Selected = True End If Catch ex As Exception 'HttpContext.Current.Response.Write("Error: <br><br>" & ex.ToString) End Try
Also note, in debugging I stop and pull my SQL Query from the code and run it in my SQL Studio...pulls one row back just like I want... WHY wont the execute scalar do it ...grr.. frustrating, makes no sence... please help :)