TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mfwamba Tshimanga
NA
155
46k
Deleting record
Jul 22 2014 11:16 AM
Hi!
Please could you have a look on my code. Its doesnt delete record. But still saying "Deleted". What happen?
private void btnDelete_Click(object sender, EventArgs e)
{
conn = new SqlConnection(connstr);
comm = new SqlCommand();
conn.Open();
SqlParameter code = new SqlParameter("@cod", SqlDbType.NChar);
SqlParameter product = new SqlParameter("@prod", SqlDbType.VarChar);
SqlParameter price = new SqlParameter("@price", SqlDbType.NChar);
comm.Parameters.Add(code);
comm.Parameters.Add(product);
comm.Parameters.Add(price);
code.Value = txtcode.Text;
product.Value = txtproduct.Text;
price.Value = txtprice.Text;
comm.Connection = conn;
comm.CommandText = @"DELETE FROM company WHERE code='@cod'";
try
{
comm.ExecuteNonQuery();
MessageBox.Show("Deleted!");
}
catch (Exception)
{
MessageBox.Show("Not deleted");
}
finally
{
conn.Close();
}
}
}
}
Reply
Answers (
2
)
Error in SQL Server
Remove rows from a datatable worked very slow