Bonjour, j'ai mis les lignes suivantes pour récupérer un resultat :
mais je ne sais pas comment récuperer la valeur len qui est egale au nombre de ligne selectionner qui me servira pour remplir mon tableau ???
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 connection.Open(); System.Data.SqlClient.SqlDataReader oDBDataReader2; String Query2 = "SELECT * FROM [StationsServices] where Axe ='" + hidTest.Value + "'"; SqlCommand cmdDatabase2 = new SqlCommand(Query2, connection); oDBDataReader2 = cmdDatabase2.ExecuteReader(); int len = ????????? ; lblresult.Text = len + " stations sur cette axe"; string[,] tabStation = new string[len, 4]; int a = 0; while (oDBDataReader2.Read() == true) { for (int i = a; i < len; i++) { tabStation[i, 0] = oDBDataReader2["Adresse"].ToString(); tabStation[i, 1] = oDBDataReader2["Name_station"].ToString(); tabStation[i, 2] = oDBDataReader2["Latitude"].ToString(); tabStation[i, 3] = oDBDataReader2["Longitude"].ToString(); a = a + 1; break; } } connection.Close();
Merci
Partager