29-05-18, 01:13 PM
ضع هذا الكود فى حدث الزر
كود :
Dim Qry As String = "SELECT Etudiants.Sexe, Etudiants.AnnéeEtude, IIf([Sexe]='1' Or [Sexe]='M' Or [Sexe]='ذ','ذكور','إناث') AS ss, IIf([AnnéeEtude]='1','السنة الأولى','السنة الثانية') AS yy, [ss] & ' ' & [yy] AS AA FROM Etudiants"
Dim SS As String = ""
If CheckBox1.Checked = True Then
SS = "Select Count([QQ].Sexe) As Counts, [QQ].ss FROM (" & Qry & ") AS [QQ] GROUP BY [QQ].ss;"
End If
If CheckBox2.Checked = True Then
If CheckBox1.Checked = True Then
SS = "Select Count([QQ].Sexe) As Counts, [QQ].AA FROM (" & Qry & ") AS [QQ] GROUP BY [QQ].AA;"
Else
SS = "Select Count([QQ].AnnéeEtude) As Counts, [QQ].yy FROM (" & Qry & ") AS [QQ] GROUP BY [QQ].yy;"
End If
End If
DataGridView1.ColumnHeadersVisible = False
Dim dt As New DataTable
Dim adp As New OleDbDataAdapter(SS, conn)
adp.Fill(dt)
DataGridView1.DataSource = dt