rickb
Member
I have a button whose text property is passed to a textbox, txtpick. The value of the textbox is used as the parameter in a SQL query, which in turn is supposed to fill a listbox. When I click on, for example, the "A" button, the txtpick textbox is filled, but the listbox isnt poplulated. Below is the code I have for the sub (LoadList). Could someone please tell me what Im missing or doing wrong? I have followed the advice of other posters who have answered similar questions, but Im having no luck.
Public Sub LoadList()
oledbconn.Open()
Dim dsUserList As New DataSet()
Dim daUserList As New OleDbDataAdapter("SELECT UserProfile, trim( LastName)" & ", " & "trim(FirstName) AS FullName,LastName,FirstName,LOC,Building,DeviceID FROM tblAS400Users WHERE LastName LIKE " & Me.txtPick.Text & "% ORDER BY LastName,FirstName", oledbconn)
Try
daUserList.Fill(dsAS400, "tblAS400USers")
With Me.lstUsers
.DataSource = dsUserList.Tables("tblAS400Users")
.DisplayMember = "FullName"
.ValueMember = "UserProfile"
End With
Catch ex As Exception
MsgBox(ex.ToString)
Exit Sub
End Try
Enable the Delete and Edit Button
cmdDelete.Enabled = True
cmdEdit.Enabled = True
oledbconn.Close()
End Sub
Here is the code for the "A" button:
Private Sub cmdA_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdA.Click
Me.txtPick.Text = cmdA.Text
LoadList()
End Sub
I do not receive an error of any type from the "Try-Catch" statement; the listbox just doesnt fill.
Thanks for any help.
Public Sub LoadList()
oledbconn.Open()
Dim dsUserList As New DataSet()
Dim daUserList As New OleDbDataAdapter("SELECT UserProfile, trim( LastName)" & ", " & "trim(FirstName) AS FullName,LastName,FirstName,LOC,Building,DeviceID FROM tblAS400Users WHERE LastName LIKE " & Me.txtPick.Text & "% ORDER BY LastName,FirstName", oledbconn)
Try
daUserList.Fill(dsAS400, "tblAS400USers")
With Me.lstUsers
.DataSource = dsUserList.Tables("tblAS400Users")
.DisplayMember = "FullName"
.ValueMember = "UserProfile"
End With
Catch ex As Exception
MsgBox(ex.ToString)
Exit Sub
End Try
Enable the Delete and Edit Button
cmdDelete.Enabled = True
cmdEdit.Enabled = True
oledbconn.Close()
End Sub
Here is the code for the "A" button:
Private Sub cmdA_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdA.Click
Me.txtPick.Text = cmdA.Text
LoadList()
End Sub
I do not receive an error of any type from the "Try-Catch" statement; the listbox just doesnt fill.
Thanks for any help.