I am doing a really simple query in ASP.NET, but after I inserted the LIKE
clause it stops working.
Example:
String sql = " SELECT *
FROM Products
WHERE ID = @MYID
AND Name LIKE '%@MYNAME%' ";
SqlCommand command = new SqlCommand(sql, cn);
command.Parameters.AddWithValue("@MYID", MYID.Text);
command.Parameters.AddWithValue("@MYNAME", MYNAME.Text);
If I removed the LIKE it works. Hence I am thinking its to do with the '' quotes?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…