Skip to content
Advertisement

sql delete statements with multiple where condition error

is this the correct statement if not plz help me correct it.

Advertisement

Answer

If your question is purely about SQL, then yes, what you have will work. But, as you have it, you have a very serious security problem. Google “SQL injection attacks”. I’m not sure what you are using for data access (ADO.NET? Entiry Framework? Dapper?) But regardless, you’ll want to use parameters:

and then:

But even then, AddWithValue isn’t the best way, because it can cause type conversion issues once the query hits the database. You are better off doing it longhand:

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement