as tu réussi à te connecter à ta base "Employé?
oui
voila j'ai trouvé ce code en cherchant sur google:
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 Const ConnectionString As String = "Data Source=best-PC\SQLEXPRESS;Initial Catalog=gestion_RH;User ID=sa;Password=*****"
Private ReadOnly Property Connection() As SqlConnection
Get
Dim ConnectionToFetch As New SqlConnection(ConnectionString)
ConnectionToFetch.Open()
Return ConnectionToFetch
End Get
End Property
Public Function GetData() As DataView
Dim SelectQry = "SELECT * FROM employe "
Dim SampleSource As New DataSet
Dim TableView As DataView
Try
Dim SampleCommand As New SqlCommand()
Dim SampleDataAdapter = New SqlDataAdapter()
SampleCommand.CommandText = SelectQry
SampleCommand.Connection = Connection
SampleDataAdapter.SelectCommand = SampleCommand
SampleDataAdapter.Fill(SampleSource)
TableView = SampleSource.Tables(0).DefaultView
Catch ex As Exception
Throw ex
End Try
Return TableView
End Function |
sur la page ou' il y' a datagridview j'ajoute :
DataGridView1.DataSource = GetData()
on m'affiche les données de la table employé.
j'aimerais afficher des informations d'autres tables qui sont liées à cette table employé.
par exemple si je sélectionne une ligne=un employé de datagridview, j'affiche
ses niveaux, son entité d'appartenance, dans des formulaires.
ces formulaires s'afficheront seulement si on sélectionne une ligne.
est ce que c'est faisable?
Partager