Click here to Skip to main content
Rate this: bad
good
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 6:16am
Comments
CHill60 at 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 at 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
0 DamithSL 320
1 OriginalGriff 155
2 Peter Leow 115
3 Afzaal Ahmad Zeeshan 114
4 deepakdynamite 110
0 OriginalGriff 7,510
1 DamithSL 5,519
2 Sergey Alexandrovich Kryukov 5,044
3 Maciej Los 4,961
4 Kornfeld Eliyahu Peter 4,514


Advertise | Privacy | Mobile
Web01 | 2.8.141223.1 | Last Updated 3 Jan 2013
Copyright © CodeProject, 1999-2014
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