Bonjour,
J'suis pas très doué en ADO et j'aimerai affiché un dataset dans un datagrid dont le dataset provient d'une requête contenant 2 tables liées
J'arrive à le faire quand il y a qu'une table mais plus d'une table c'est la galère.
j'ai essayé un truc du genre mais sans succès car il n'y a rien qui s'affiche.
Merci d'avance
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 Try If MyConnexion.State = ConnectionState.Closed Then MyConnexion.Open() Dim MyDataSet As New DataSet Dim MyObjetCommand As New OleDbCommand("SELECT * FROM Table1", MyConnexion) Dim MyDataAdapter As New OleDbDataAdapter(MyObjetCommand) Dim MyObjetCommand2 As New OleDbCommand("SELECT * FROM Table2", MyConnexion) Dim MyDataAdapter2 As New OleDbDataAdapter(MyObjetCommand2) MyDataAdapter.Fill(MyDataSet, "Table1") MyDataAdapter2.Fill(MyDataSet, "Table2") MyDataSet.Relations.Add("MyRelation", MyDataSet.Tables("Table1").Columns("Index_Table1"), MyDataSet.Tables("Table2").Columns("Index_Table1")) MyDataGrid.DataSource = MyDataSet Catch ex As Exception MessageBox.Show(ex.ToString, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information) Finally If MyConnexion.State = ConnectionState.Open Then MyConnexion.Close() End Try![]()
Partager