Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL code for delete Row?

Tags:

c#

sql

sql-server

please anyone to explain me what is the problem with following code why didn't delete Table Row.

con.Open();
SqlCommand cmd = new SqlCommand("delete from RentTable where CID = '" + ID + "' and MID = '" + MID + "' )", con);
int result = cmd.ExecuteNonQuery();
if (result == 1)
{
    Message = "succsess";
}
else
{
    Message = "!";
}
con.Close();
like image 247
user2800704 Avatar asked May 25 '26 15:05

user2800704


1 Answers

75% of all these types of problems would be fixed if people loaded their queries into a string variable first then printed them out for debugging purposes :-)

You have a closing parenthesis ) at the end of your query which shouldn't be there.

like image 76
paxdiablo Avatar answered May 28 '26 12:05

paxdiablo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!