Incorrect Syntax Near % Sql Parameter In C#.NET and SQL Server
When writing sql statements in your business logic layer, you often want to append % which is a literal in your query. An example would be like this:
However, this would give you an error, since the @family parameter is inside the tick marks that makes it a literal, but the % sign should be inside the tick marks. So, the correct sql syntax would be this way:
Source: VBForums Link
string query = "Select * from Patient where LastName like '" + "@family" + " %'";
string query = "Select * from Patient where LastName like (@family + '%')";
this helped alot..keep it up..thnx!
ReplyDeleteTnx jerbs.. :)
Delete