0

I was wondering if you could help me out, I'm trying to do a DB Add, Update, Delete program and I was using your program khanhtrung for assistance and got the ADD working perfectly but UPDATE/DELETE will not work whatsoever, this is my code for my delete button, and for the delete part it's pretty much the same syntax and it keeps catching at the executenotquery line. If somebody could help me out I'd really appreciate it. Thank you.

private void btnDelete_Click(object sender, EventArgs e)
        {
            if (MAconn != null && MAconn.State == ConnectionState.Open)
            {
                MAconn.Close();
                MAcmd.Dispose();
            }

            try
            {
                MAconn = new OleDbConnection();
                MAconn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Users\\John\\Desktop\\C# Final Project\\TicketReservationSystem\\Database1.mdb";
                MAconn.Open();
                MAcmd = MAconn.CreateCommand();
            }
            catch
            {
                MessageBox.Show("Database unable to be opened.");
                return;
            }

            MAcmd.CommandText = "DELETE FROM EventTable " +
                                "WHERE EventName = " + cmbEventList.Text;
            try
            {
                int row_affected = MAcmd.ExecuteNonQuery();
                MessageBox.Show("Artist was successfully removed from event list", "Success",
                    MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch
            {
                MessageBox.Show("Error removing artits", "Error",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by __avd
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.