Ive been having a hard time finding a solution for my problem, I want to display all the columns on my DB in SQL in my ListBox... anyone have an idea? please do help me?
Here is my codes:
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
Try
Dim thisConnection As New SqlConnection("Data Source=#####;Initial Catalog=####;Persist Security Info=True;User ID=#####;Password=#####")
thisConnection.Open()
Dim sql As String = ("SELECT ControlNo,EmpNo,CheckOutDate,CheckOutTime,TaxiNo,PlateNo,Model,Make FROM dbo.ChkInOut WHERE ControlNo='" & txtsearch.Text & "'")
Dim da As New SqlDataAdapter(sql, thisConnection)
da.Fill(ds, "dbo.ChkInOut")
Dim dt As DataTable = ds.Tables("dbo.ChkInOut")
ListBox1.DataSource = dt
ListBox1.DisplayMember = ("ControlNo")
txtCtrlNo.DataBindings.Add("text", dt, "ControlNo")
txtEmpNo.DataBindings.Add("text", dt, "EmpNo")
txtCheckOutDate.DataBindings.Add("text", dt, "CheckOutDate")
txtCheckOutTime.DataBindings.Add("text", dt, "CheckOutTime")
txtTaxiUnitNo.DataBindings.Add("text", dt, "TaxiNo")
txtPlateNo.DataBindings.Add("text", dt, "PlateNo")
txtModel.DataBindings.Add("text", dt, "Model")
txtMake.DataBindings.Add("text", dt, "Make")
thisConnection.Close()
Catch ex As Exception
End Try
End Sub
';DROP Table dbo.ChkInOut;--into your search field. After this, the ListBox will be showing all columns still in your table.