bonjour a tous voila j ai un petit soucis auquel j espere vous pourrez m aider je travaille sur vb 2013 avec une base de donnee de type mysql je voudrai faire une recherche sur 2 parametre mais ca ne fais rien pouvez vous m aider a trouver mon erreur merci

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 
 Private Sub cmdrechercheclt_Click(sender As Object, e As EventArgs) Handles cmdrechercheclt.Click
        If cn.State = ConnectionState.Closed Then
            cn.Open()
 
            If txtrecherchecontact.Text = "" And txtrechercheclt.Text = "" Then 'recherche siles 2 champs recherche sont VIDE
                ListView1.Items.Clear()
                recherche_vide()
                cn.Close()
            End If
 
            If txtrecherchecontact.Text <> "" And txtrechercheclt.Text <> "" Then
                Dim valeur As String = txtrechercheclt.Text
                Dim valeur1 As String = txtrecherchecontact.Text
                Dim cmd As String = "SELECT * FROM client  WHERE (nomclt LIKE '%" & valeur & "%') OR (contactclt LIKE '%" & valeur1 & "%')"
                ListView1.Items.Clear()
                recherche(cmd)
                'cn.Close()
 
            End If
 
 
        End If
 
    End Sub
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 
Sub recherche(ByVal cmd_valeur As String)
        ListView1.Items.Clear()
 
        Dim cmd As New MySqlCommand(cmd_valeur, cn)
        Using L As MySqlDataReader = cmd.ExecuteReader()
            While L.Read()
                Dim nomclt As String = L("nomclt")
                Dim contactclt As String = L("contactclt")
                Dim telclt As String = L("telclt")
                Dim adresseclt As String = L("adresseclt")
                Dim commentclt As String = L("commentclt")
 
                ListView1.Items.Add(New ListViewItem(New String() {nomclt, contactclt, telclt, adresseclt, commentclt}))
            End While
        End Using
    End Sub