0

Hello Guys! I am using listview. i want to search using textbox records from the database and display the searched records in listview. i read some post here with same/like mine but they're using datagrid. :|

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by marcmanlin2
0
ListBox1.Items.Clear()
        Try
            con.Open()

            Dim da As New SqlDataAdapter("select * from student where id="+Me.TextBox1.Text, db.con)
            Dim ds As New DataSet
            da.Fill(ds, "1")

                   For i As Integer = 0 To ds.Tables("1").Rows.Count - 1
                Me.ListBox1.Items.Add(ds.Tables("1").Rows(i)(0) + "  -  " + ds.Tables("1").Rows(i)(1))
            Next

        Catch ex As Exception
            MsgBox("Error : " + ex.Message)
        Finally
con.Close()
        End Try

Here con is a SqlConnection object...

try this....

0

Hello Guys! I am using listview. i want to search using textbox records from the database and display the searched records in listview. i read some post here with same/like mine but they're using datagrid. :|

Private Sub Button3_Click_1(sender As System.Object, e As System.EventArgs) Handles Button3.Click
        L1.Items.Clear()

        mysql = "SELECT * FROM student where ln like '" & TextBox5.Text & "%'"
        Dim ream As OleDbDataReader
        comg = New OleDbCommand(mysql, conn)
        ream = comg.ExecuteReader

        While ream.Read
            With L1
                .Items.Add(ream("id"))
                With .Items(.Items.Count - 1).SubItems
                    .Add(ream("fn"))
                    .Add(ream("mi"))
                    .Add(ream("ln"))
                End With
            End With
        End While
    End Sub
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.