0

I am using ADO.net and using SqlParameter passing into a stored procedure a group of words that sometimes may have a + between then. Up until the plus sign the search is working fine but once I add it I am getting no results. Do I need to change anything in the c# code I am run the sp fine with the plus sign.

c# code

SqlParameter[] parms = new SqlParameter[] {
    new SqlParameter("@Title", SqlDbType.VarChar)
};
parms[0].Value =Title;

SQL SP

create PROCEDURE [usp_Select_Title] -
    -- Add the parameters for the stored procedure here  
@Title nvarchar(512) = null




WHERE (dcc.Title like '%'+ @Title +'%') 
Jefferson
  • 173
  • 2
  • 12
  • 32

1 Answers1

2

As per the discussion in comment, the value was passed to via query string in URL. In this the case the + sign has a semantic meaning in the query string which is used to represent a space.

So, the solution for this is to encode the + sign with %2B in URL and decode back to + in C#.

References:

Albert Einstein
  • 7,472
  • 8
  • 36
  • 71