private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { kunder k = (kunder)listBox1.SelectedItem; MySqlConnection connection = new MySqlConnection(ConnString); connection.Open(); k.Omsattning = 0; MySqlCommand cmd = k.GetUpdateCommand(); cmd.Connection = connection; cmd.ExecuteNonQuery(); connection.Close(); }
private void button2_Click(object sender, EventArgs e) { kunder k = new kunder(); k.FirmaNamn = "Raffes Korvkiosk"; k.Kund_ID = "RAFFE"; k.Omsattning = 1000; MySqlConnection connection = new MySqlConnection(ConnString); connection.Open(); MySqlCommand cmd = k.GetInsertCommand(); cmd.Connection = connection; try { cmd.ExecuteNonQuery(); } catch (MySqlException exc) { MessageBox.Show(exc.Message); } connection.Close(); }