Donnez votre avis

(class & module) Remplir combo d'un autre form

Posez votre question

Remplir combo d'un autre form



Imports


Imports System.Data

Imports System.Data.OracleClient

Classe de connection


Public Class connectionclass

    Public connection As OracleConnection
    Public command As OracleCommand
    Public objDataSet As DataSet
    Public Adapter As OracleDataAdapter    

    Sub New()
        connection = New OracleConnection()
        connection.ConnectionString = "votre chaine" 
    End Sub

    Public Sub ouverture()
        connection.Open()
    End Sub

    Public Function getConnection()
        Return (connection)
    End Function

    Public Sub fermeture()
        connection.Close()
    End Sub

    Public Sub insertion(ByVal req1 As String)
        command = New OracleCommand(req1, connection)
    End Sub

    Public Sub command_new()
        command = New OracleCommand()
    End Sub

    Public Function getcommand()
        Return command
    End Function

end class

Procédure de remplissage du combo


Sub remplir_combobox(ByVal combo As ComboBox, ByVal requete As String, ByVal champ_afficher As String, ByVal champ_value As String)
        Try
            OBconnc = New connectionclass()
            OBconnc.ouverture()
            OBconnc.insertion(requete)
            comm = OBconnc.getcommand()
            reader = comm.ExecuteReader()
            combo.Items.Clear()
            combo.ValueMember = champ_value 'puisque la combobox a une valeur afficher 
            combo.DisplayMember = champ_afficher 'et une pris come value
            While (reader.Read())
                If (reader(0).ToString() <> Nothing) Then
                    combo.Items.Add(reader(0))
                End If
            End While
            reader.Close()
            combo.Update()
            combo.Refresh()
        Catch ex As Exception
            MsgBox(ex.Message & "erreur c'est produite lors de l'extraction d'information")
        End Try
    End Sub
Ajouter un commentaire

Commentaires

Commenter la réponse de mounirCrAzY