Hello,
I have the code for deleting a record from a table
through bindNavigator Delete button. My problem is when i click on
delete button it deletes the previous record.
How can i delete the correct record?
Thank you
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Kirtan PatelPosted Oct 19, 2009, 1:18 AM
Problem Solved :)
I Changed The connection String ..in code to connect it with my server so change it :)
and One more thing when you delete record you need to first delete Sub Records of Order Table First :) may be it will
cause exception while deleting .
Problem was occurring because when we click on delete Button the Contex of dataBinding Moving to Previous DataRecord ..
but it was just logically deleted the Item But Not Physically deletes the Item
so i have captured the value in TextBox before it movies to previous Record Context.
Corrected Project Files(Updated..)
dont forget to mark "do you like this answer" please :)
Kirtan PatelPosted Oct 19, 2009, 8:08 AM
Cancel part of dialog box
else if (x == DialogResult.Cancel)
{
MessageBox.Show("Abort");
//Added Code
int z = itmBindNavigator.BindingSource.Position;
button1.PerformClick();
itmBindNavigator.BindingSource.Position = z+1;
}
DealyPosted Oct 19, 2009, 7:20 AM
Kirtan PatelPosted Oct 19, 2009, 4:30 AM
what do you mean by changing record ????after deleting ??
DealyPosted Oct 19, 2009, 3:09 AM
One more question... is it possible to change record after the confirmation of delete, not as soon as the user clicks on delete?
Kirtan PatelPosted Oct 18, 2009, 9:31 AM
Its Seems no Problem with code but if you can provide me Project Files then i could quickly resolve problem
I have Northwind Database please send me Only Project Files(zipped) at [email protected] :)
I will Quickly resolve your problem :)
Thank you :)
DealyPosted Sep 3, 2009, 1:16 AM
still having the same problem so i would appreciate if you could check my code. Here's the code for Nortwind example:
Thank you again.
Master BillaPosted Sep 2, 2009, 10:55 PM
You can use my code
thank you
Kirtan PatelPosted Sep 2, 2009, 9:09 PM
if Still Having Problem then you are having problem with your stored Procedure
if (MessageBox.Show("Are you sure you want;", "Confirm Deletion", MessageBoxButtons.OKCancel) == DialogResult.OK)
{
string connectionString = GetConnection();
SqlConnection conn = new SqlConnection(connectionString);
SqlCommand command = new SqlCommand("DELETE_COMMAND", conn);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.AddWithValue("@C_IDENTITY", c_identity_txt.Text);
conn.Open();
int rows = command.ExecuteNonQuery();
conn.Close();
if (rows > 0)
{
MessageBox.Show("Success");
}
else
{
MessageBox.Show("Failure");
}
}
else
{
MessageBox.Show("Cancelled");
}
DealyPosted Sep 2, 2009, 8:31 AM
Kirtan PatelPosted Sep 2, 2009, 7:16 AM
Can you Provide me the code you are using to delete a Record I will Provide you Correct code :)
Roei BarPosted Sep 2, 2009, 7:04 AM
DealyPosted Sep 2, 2009, 6:02 AM
Roei BarPosted Sep 2, 2009, 5:58 AM
you delete one record and upon deleting the other you delete the prevoius
meaning you need to rebind the BindingNavigator ;-)