public override string ToString() { return(_da.ToString()); }
private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e) { SqlConnection connection; Console.WriteLine(proivinchie); string connectionString; string commandText = "SELECT * From GEMEENTE WHERE Gemeente =@plaats"; connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["WindowsFormsApp5.Properties.Settings.Database1ConnectionString"].ConnectionString; using (connection = new SqlConnection(connectionString)) { SqlCommand command = new SqlCommand(commandText, connection); command.Parameters.AddWithValue("@plaats", proivinchie); //command.Parameters.Add("@plaats", SqlDbType.VarChar); //command.Parameters["@plaats"].Value = plaats; connection.Open(); using (SqlDataAdapter adapter = new SqlDataAdapter(command)) { Console.WriteLine(adapter.ToString()); DataTable GEMEENTE = new DataTable(); adapter.Fill(GEMEENTE); this.chart1.Series["Groen1"].Points.Clear(); foreach (DataRow row in GEMEENTE.Rows) { Console.WriteLine("Hallo"); if (checkedListBox1.GetItemCheckState(0) == CheckState.Checked) { Console.WriteLine("piet"); this.chart1.Series["Groen1"].Points.AddXY("2010", row["J2010"].ToString()); } if (checkedListBox1.GetItemCheckState(1) == CheckState.Checked) { Console.WriteLine("piet"); this.chart1.Series["Groen1"].Points.AddXY("2011", row["J2011"].ToString()); } if (checkedListBox1.GetItemCheckState(2) == CheckState.Checked) { this.chart1.Series["Groen1"].Points.AddXY("2012", row["J2012"].ToString()); } if (checkedListBox1.GetItemCheckState(3) == CheckState.Checked) { this.chart1.Series["Groen1"].Points.AddXY("2013", row["J2013"].ToString()); } if (checkedListBox1.GetItemCheckState(4) == CheckState.Checked) { this.chart1.Series["Groen1"].Points.AddXY("2014", row["J2014"].ToString()); } if (checkedListBox1.GetItemCheckState(5) == CheckState.Checked) { this.chart1.Series["Groen1"].Points.AddXY("2015", row["J2015"].ToString()); } if (checkedListBox1.GetItemCheckState(6) == CheckState.Checked) { this.chart1.Series["Groen1"].Points.AddXY("2016", row["J2016"].ToString()); } } } } }