Dim con As New MySqlConnection("Data Source=localhost;Database=coa;User=root;Password=12345") Dim da As New MySqlDataAdapter Dim dt As New DataTable Dim sql As String sql = "Select PhoneNumber, FirstName, LastName, Course, Year From students" sql = sql & " Where Course like '" & cbc.Text & "'" sql = sql & " Where Year like '" & cby.Text & "'" With cmd .CommandText = sql .Connection = con End With With da .SelectCommand = cmd .Fill(dt) End With 'for clearing list view myview1.Items.Clear() If dt.Rows.Count = 0 Then MessageBox.Show("No Record Found.", "Check Again", MessageBoxButtons.OK, MessageBoxIcon.Information) Exit Sub End If For i = 0 To dt.Rows.Count - 1 With myview1 .Items.Add(dt.Rows(i)("PhoneNumber")) With .Items(.Items.Count - 1).SubItems .Add(dt.Rows(i)("FirstName")) .Add(dt.Rows(i)("LastName")) .Add(dt.Rows(i)("Course")) .Add(dt.Rows(i)("Year")) End With End With Next End Sub
where
and
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)