Bonjour,
je me trouve coincé avec cette methode je poste le code ..je cherche à comprendre ce quel fait cette methode..sachant que je cherche à afficher les informations sur ma base qui concerne le nom du client que je tape son nom
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
 
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim NOMcli As String
 
        NOMcli = TextBox20.Text
        rechercheclient(NOMcli)
        DataGrid1.SetDataBinding(DataSetresultatrecherche2, "Tclient")
    End Sub
    Public Function recherche(ByVal dataadapter As OleDb.OleDbDataAdapter, ByVal nomtable As String, ByVal champs As String, ByVal parametres As OleDb.OleDbParameter()) As DataTable
        Dim derniereErreur As String
        Dim separateur As String
        If nomtable.IndexOf("where") > 1 Then
            separateur = "and"
        Else
            separateur = "where"
        End If
        Try
            MsgBox("recherche" & nomtable)
            recherche = New DataTable(nomtable)
            MsgBox("recherche" & nomtable)
            dataadapter.SelectCommand.CommandText = "select" + champs + "from" + nomtable
            dataadapter.SelectCommand.Parameters.Clear()
            Dim parametre As OleDb.OleDbParameter
            For Each parametre In parametres
                If parametre.Value <> Nothing Then
                    MsgBox("paramname" & parametre.ParameterName)
                    dataadapter.SelectCommand.CommandText = dataadapter.SelectCommand.CommandText + separateur + parametre.ParameterName + "=?"
                    dataadapter.SelectCommand.Parameters.Add(parametre)
                    separateur = "and"
                End If
            Next
            DataSetresultatrecherche2 = New DataSet()
            DataSetresultatrecherche2.Tables.Add(recherche)
            dataadapter.Fill(recherche)
            derniereErreur = ""
        Catch except As Exception
            recherche = Nothing
            derniereErreur = except.Message
        End Try
    End Function
    Public Function rechercheclient(ByVal nomcli As String) As DataTable
 
        rechercheclient = recherche(OleDbDataAdapter1, "Tclient", "Numclt,Nomclt,Adrclt,Vilclt,Telclt", New OleDb.OleDbParameter() {New System.Data.OleDb.OleDbParameter("Nomclt", nomcli)})
    End Function