Example #1
0
        internal void updateInvoice(Invoice invoice)
        {
            try
            {
                string sql = "UPDATE Invoice SET Total = @total, Miles = @miles WHERE InvoiceId = @invoiceId";

                conn = new MySql.Data.MySqlClient.MySqlConnection(myConnectionString);

                MySqlCommand command = new MySqlCommand(sql, conn);
                command.Parameters.AddWithValue("total", invoice.getTotal());
                command.Parameters.AddWithValue("miles", invoice.getMiles());
                command.Parameters.AddWithValue("invoiceId", invoice.getInvoiceId());

                conn.Open();

                command.ExecuteNonQuery();

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                conn.Close();
            }
        }