private void button1_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Server=MASTER;DataBase=iTylerHood;Integrated Security=SSPI"); SqlCommand cmd = new SqlCommand("CustomerByCountry",con); cmd.CommandType = CommandType.StoredProcedure; con.Open(); ArrayList al = new ArrayList(); SqlDataReader dr = cmd.ExecuteReader(); while(dr.Read()) { object[] values = new object[dr.FieldCount]; dr.GetValues(values); al.Add(values); } dr.Close(); con.Close(); foreach(object[] row in al) { foreach(object column in row) { listBox1.Items.Add(column.ToString()); } } //------ Convert to Int Array int[] ia = (int[])al.ToArray(typeof(int)); int sum = 0; for (int i = 0; i < ia.Length; i++) sum += ia[i]; //------- Display on Chart string[] seriesArray = { "Fish", "Sharks" }; this.chart1.Palette = ChartColorPalette.SeaGreen; this.chart1.Titles.Add("Pets"); for (int i = 0; i < seriesArray.Length; i++) { Series series = this.chart1.Series.Add(seriesArray[i]); series.Points.Add(ia[i]); } }
ArrayList
System.Collections.Generic.List<>
ToArray
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)