troubleshooting Question

Delete Query Statement With two conditions does not work

Avatar of G F
G FFlag for Canada asked on
.NET ProgrammingDatabasesC#MySQL Server
9 Comments1 Solution55 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:


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



Any thoughts or help would be appreciated.

Thank you,

General Manager

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 9 Comments.
Start Free Trial
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 1 Answer 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