title: SqlDataSource SelectCommand using 2 Parameters and LIKE does not work
body: <p>I have the following selectcommand in a SqlDataSource, my problem is that it only returns data when I have values for both Parameters. I need it to also return data when only 1 has a value.</p>
  
  <pre><code>SelectCommand="SELECT user.UserId, UserProfiles.Company, UserProfiles.Address, UserProfiles.JV2, UserProfiles.DB1, aspnet_Membership.Email, user.UserName
  FROM user INNER JOIN UserProfiles ON user.UserId = UserProfiles.UserId  WHERE        (@UserName  IS NULL OR @UserName = ''  OR user.UserName LIKE '%'+@UserName+'%' ) AND
                       (@Email IS NULL  OR @Email = '' OR user.Email LIKE '%'+@Email+'%') 
  </code></pre>
  
  <p>with the following Parameters</p>
  
  <pre><code>   &lt;SelectParameters&gt;  
      &lt;asp:ControlParameter Name="Email" ControlID="eMail"  PropertyName="Text" Type="String"  /&gt;
  &lt;asp:ControlParameter Name="UserName" ControlID="userName"  PropertyName="Text" Type="String"  /&gt;
  </code></pre>
  
  <p></p>
  
  <p>When I run the query in SQL Server Management Studio and it returns data when I enter only 1 value or both. 
  When I run the form I only get data returned when I enter values in to both fields. </p>
  
  <p>I found this post: <a href="https://stackoverflow.com/questions/687677/sqldatasource-selectcommand-using-like-does-not-work">SqlDataSource SelectCommand using LIKE does not work</a> which is similar but the solution hasn't helped.</p>
  
  <p>Obviously I've done something wrong, I just can't see what. </p>