Bonjour,

j'aimerais remplir ma gridview via plusieurs requêtes. J'utilise actuellement un DataTable qui permet de structurer mes colonnes. Je dois utiliser exactement 2 requêtes différentes, mais mes résultats ne s'affichent pas dans la bonne colonne.

Voici mon code :
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
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
 
 //affichage dans GridView Semaine
        DataTable myTable = new DataTable();
        myTable.Columns.Add("Jour");
        myTable.Columns.Add("Nb TK créés");
        myTable.Columns.Add("Nb TK Clôturés");
 
        SqlConnection myConnexionTKCree = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionStringHotlineSQL"].ToString());
        SqlConnection myConnexionTKClot = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionStringHotlineSQL"].ToString());
 
        SqlCommand myCommandTKCree = new SqlCommand("SELECT COUNT(*) AS NbTKcree, DATEPART(dd,DateDebut) AS DateDebut FROM T_TICKET INNER JOIN T_INTERVENANT_TICKET ON T_TICKET.IDTicket = T_INTERVENANT_TICKET.IDTicket WHERE T_INTERVENANT_TICKET.IDActeur LIKE " + ddlInter.SelectedValue.ToString() + " GROUP BY DATEPART(dd,DateDebut) ORDER BY DATEPART(dd,DateDebut)", myConnexionTKCree);
        SqlCommand myCommandTKClot = new SqlCommand("SELECT COUNT(*) AS NbTKclot FROM T_TICKET INNER JOIN T_INTERVENANT_TICKET ON T_TICKET.IDTicket = T_INTERVENANT_TICKET.IDTicket WHERE T_INTERVENANT_TICKET.IDActeur LIKE " + ddlInter.SelectedValue.ToString() + " AND DateFin IS NOT NULL GROUP BY DATEPART(dd,DateDebut) ORDER BY DATEPART(dd,DateDebut)", myConnexionTKClot);
 
        myConnexionTKCree.Open();
 
        SqlDataReader myReaderTKcree = myCommandTKCree.ExecuteReader();
        ArrayList myList;
        while (myReaderTKcree.Read())
        {
            myList = new ArrayList();
 
            myList.Add(myReaderTKcree["DateDebut"].ToString());
            myList.Add(myReaderTKcree["NbTKcree"].ToString());
 
            myTable.Rows.Add(myList.ToArray());
        }
        myConnexionTKClot.Open();
 
        SqlDataReader myReaderTKClot = myCommandTKClot.ExecuteReader();
        while (myReaderTKClot.Read())
        {
            if (myReaderTKClotM["NbTKclot"].ToString()=="")
            {
                myTable.Rows.Add("0");
            }
            else
            {
                myTableMois.Rows.Add(myReaderTKClotM["NbTKclot"].ToString());
            }
        }
 
        gvRapportS.DataSource = myTable;
        gvRapportS.DataBind();
        myConnexionTKCree.Close();
        myReaderTKClot.Close();
        myReaderTKcree.Close();
        myReaderTKClot.Close();
Voici mon résultat :



Si vous avez des idées sur une éventuelle solution, je suis preneur car ça me prend la tête.

Merci d'avance