Im trying to learn using MySQl with C# so im creating app that allow sorting and adding data to my tables.
That is code that i use to show items selected only by my comboBox_1 value. But now i want to add 2nd comboBox and show data that meets both conditions. The problem is i have no idea how to get there. I thought using multiple ifs that check if combobox have any items selected but my code is looking monstrous then.
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if(comboBox1.SelectedIndex >= 0)
{
MySqlDataAdapter adapter = new MySqlDataAdapter("SELECT * FROM narzedzia.narzedzia where status='" + comboBox1.Text + "'", Program.connection);
if (Program.connection.State == ConnectionState.Closed) { Program.connection.Open(); }
DataSet ds = new DataSet();
adapter.Fill(ds, "narzedzia");
dataGridView1.DataSource = ds.Tables["narzedzia"];
Program.connection.Close();
}
}```