SQL delete command?

后端 未结 7 2283
日久生厌
日久生厌 2020-12-18 02:34

I am having trouble with a simple DELETE statement in SQL with unexpected results , it seems to add the word to the list??. Must be something silly!. but i cannot see it , t

7条回答
  •  被撕碎了的回忆
    2020-12-18 03:07

    See the code below:

    String queryForUpdateCustomer = "UPDATE  customer SET cbalance=@txtcustomerblnc WHERE cname='" + searchLookUpEdit1.Text + "'";
                try
                {
                    using (SqlCommand command = new SqlCommand(queryForUpdateCustomer, con))
                    {
    
                    command.Parameters.AddWithValue("@txtcustomerblnc", txtcustomerblnc.Text);
    
    
                    con.Open();
                    int result = command.ExecuteNonQuery();
    
                    // Check Error
                    if (result < 0)
                        MessageBox.Show("Error");
    
                    MessageBox.Show("Record Update of Customer...!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    con.Close();
    
                    loader();
                }
    
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                con.Close();
            }
    

提交回复
热议问题