Getting query result in a variable
Posted on 2008-06-12
please see the code.
Private Sub list1_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles list1.Validated
Dim v_titlecode As String = "test"
Dim a As Object
sel_stat2 = "SELECT title_code FROM ch_account_titles WHERE title_desc = ' " & list1.SelectedItem & " '"
Dim sel2 As New SqlCommand(sel_stat2, Conn)
acctitle.Text = sel2.ExecuteScalar()
Now my requirement is that if user selects "ASSETS" from list then title_code which is "A" in table should be writen to acctitle.text field. but it shows nothing there.
i think my question is clear and well understandable.