What is the best way to run a custom expression sqlusing INfrom C # LinQ to sql datacontext? I tried:
db.ExecuteCommand(
"UPDATE tblCard SET used = 1 WHERE id IN ({0}) AND customer_id = {1}",
Request.Form["ids"], customer_id
);
This is normal for 1 element that passed through the form, but if I get a message through, for example, "2.1", then I get an exception sqlclient:
Conversion error when converting nvarchar '2.1' value to int data type.
If instead I use string.format to insert a parameter, it works fine, but obviously it is open to SQL injection.
source
share