troubleshooting Question

Delete Query Statement With two conditions does not work

Avatar of G F
G FFlag for Canada asked on
DatabasesMySQL Server.NET ProgrammingC#
9 Comments2 Solutions55 ViewsLast Modified:
Hi, I have a MySQL/Maria Database application written in C#.

I come to a point where I want to execute a Delete Query using two conditions, but I'm having issues putting it together.

I've tried these two statements, both error out saying I need to look at the Database Manual:



MySqlCommand cmd = new MySqlCommand("DELETE from bbb.traveldocumentsterritories (TDId,TerritoryName)" + "VALUES(@TDId,@TerritoryName)", con);




MySqlCommand cmd = new MySqlCommand("DELETE from bbb.traveldocumentsterritories WHERE TDId=@TDId AND TerritoryName=@TerritoryName)", con);



It's just one table, one record using two columns, so I don't need a Join statement or something, I'm just not sure what I'm missing.

I've double checked the name of the database and the names of the columns, and they are fine.

Here is the rest of the code:



con.Open();

            cmd.Parameters.AddWithValue("@TDId", txtBox_TD_Current_ID.Text);
            cmd.Parameters.AddWithValue("@TerritoryName", idvalue3);

            cmd.ExecuteNonQuery();


            con.Close();





Any thoughts or help would be appreciated.

Thank you,

G
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 9 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros