salut dans un de mes soft, j'avais ces deux fonctions dans un module :
'Rafraichissement d'un Combobox Public Sub RefreshCb(ByVal Combo As ComboBox, ByVal Table As String, ByVal Champs() As String, ByVal Index As Integer) Combo.DataSource = AfficherTout(Table) Combo.DisplayMember = Champs(Index).ToString End Sub
'Fonction de recherche dans la table Public Function AfficherTout(ByVal table As String) As DataView Dim SourceConnect As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Nomdelabasededonnée SourceOle = New OleDbConnection(SourceConnect) Select Case SourceOle.State Case ConnectionState.Closed SourceOle.Open() End Select Try RequeteSQL = "SELECT * FROM " & table Dim DataA As New OleDbDataAdapter(RequeteSQL, SourceOle) Dim DataS As New DataSet DataA.Fill(DataS, table) Dtt = DataS.Tables(table) Try 'return incorrect sur du Update Return DataS.Tables(table).DefaultView Catch ex As Exception Return Nothing Finally Select Case SourceOle.State Case ConnectionState.Open SourceOle.Close() SourceOle.Dispose() SourceOle = Nothing SourceConnect = "" End Select End Try Catch ex As Exception Return Nothing End Try End Function
et dans le formulaire, j'appelais le rafraichissement comme ceci :
RefreshCb(Nomducombobox, Nomdetatable, NomduChamps, Indexduchamps)
en esperant que ça te servira ... @+ greg38bj
|