Click here to Skip to main content
12,446,296 members (53,713 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#
query = "DELETE FROM Customer WHERE Account_No=@Account_No";
 
                                       SqlCommand cmd = new SqlCommand(query, cn);
                                       cmd.Parameters.AddWithValue("@Account_No", txtaccount1.Text + "-" + txtaccount2.Text);
                                       cn.Open();
                                       cmd.ExecuteNonQuery();
                                       cn.Close();
                                        MessageBox.Show("Record Deleted Successfully", "Success Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
Posted 3-Jan-13 5:16am
Comments
CHill60 3-Jan-13 11:25am
   
Are you saying that you want to set the Customer.Account_No to blank? If so then you need to use an UPDATE clause in your SQL not DELETE
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

TRY THIS

query = "UPDATE Customer 
SET Account_No=NULL
WHERE Account_No=@Account_No";
  Permalink  
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Hi

You need Update Account_No to a value for example Null or other not exist value.

If you need more help, please share your table structure with current values and final values you need.
  Permalink  
Comments
Reza Alipour Fard 3-Jan-13 13:34pm
   
I present a solution and for more detail I said if need to more help clarification.
Why you get Down voted???
I think you have wrong in this action.
However, Thank you for your attention.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160811.3 | Last Updated 3 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100