Dim MyQuery As String = " SELECT Job FROM [Jobs$] WHERE [Job] IS NOT NULL" cn.Open() da = New OleDb.OleDbDataAdapter(MyQuery, cn) da.Fill(ds, "Job") count = ds.Tables(0).Rows.Count.ToString da.Dispose() ds.Clear() cn.Close() Catch ex As Exception MessageBox.Show(ex.Message, "CreateButtonsSaveMutu") Finally End Try
Dim MyButton As New Button() MyButton.Location = New Point(705, intPos) MyButton.Height = 40 MyButton.Width = 180 MyButton.Text = "* [Tous les clients]" & " ( " & count & " )" MyButton.Name = MyLabel4.Text MyButton.Tag = "*" MyButton.BackColor = Color.Cornsilk intPos = intPos + 42 Me.Controls.Add(MyButton) AddHandler MyButton.Click, AddressOf MyButton_Click
Mon problème, je souhaiterai créer les boutons :
SV_CLIENT1 (nombre de jobs)
SV_CLIENT2 (nombre de jobs)
...
Try cn.ConnectionString = " Provider=Microsoft.ACE.OLEDB.12.0;" & _ " Data Source=" & PathTeam & Customers.Keys(0) & FilePDP & _ "; Extended Properties=""Excel 12.0;HDR=YES;Persist Security Info=False" & """" Dim MyQuery As String = " SELECT COUNT(*), Environnement " & _ " FROM [Jobs$] WHERE [Environnement] IS NOT NULL " & _ " GROUP BY [Environnement]" cn.Open() da = New OleDb.OleDbDataAdapter(MyQuery, cn) da.Fill(ds, "Environnement")
For Each cRow In ds.Tables(1).Rows MessageBox.Show("Check environnement" & vbCrLf & vbCrLf & cRow("Environnement").ToString() & _ vbCrLf & vbCrLf & ds.Tables(1).Rows.Count.ToString & _ vbCrLf & vbCrLf & "test", "Check SAVEMUTU - Client") Exit For Next
da.Dispose() ds.Clear() cn.Close() Catch ex As Exception MessageBox.Show(ex.Message, "CreateButtonsSaveMutu") End Try
ds.Tables(1).Rows.Count.ToString me donne bien le nombre de client.
La boucle "For Each cRow In ds.Tables(1).Rows" m'énumère correctement le noms des clients (Environnement).
Comment récupérer le Count(*) des jobs pour chaque client ???