Avatar of G F
G F
Flag for Canada

asked on 

Delete Query Statement With two conditions does not work

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
.NET ProgrammingDatabasesC#MySQL Server

Avatar of undefined
Last Comment
Chinmay Patel

8/22/2022 - Mon