title: How to use wildcards in SQL query with parameters
body: <p>Say I have a basic query, something like this:</p>
  
  <pre><code> SELECT holiday_name
   FROM holiday
   WHERE holiday_name LIKE %Hallow%
  </code></pre>
  
  <p>This executes fine in my sql query pane and returns 'Halloween'.  My problem occurs when I try to use parameters with with the wildcard '%' characters in my code.</p>
  
  <pre><code>SqlConnection Connection = null;
  SqlCommand Command = null;
  
  string ConnectionString = ConfigurationManager.ConnectionStrings["SQLdb"].ConnectionString;
  string CommandText = "SELECT holiday_name "
                     + "FROM holiday "
                     + "WHERE holiday_name LIKE %@name%";
  Connection = new SqlConnection(ConnectionString);
  
  try
  {
        Connection.Open();
        Command = new SqlCommand(CommandText, Connection);
        Command.Parameters.Add(new SqlParameter("name", HolidayTextBox.Text));
        var results = Command.ExecuteScalar();
  }
  
  catch (Exception ex)
  {   
       //error stuff here       
  }
  
  finally
  {
      Command.Dispose();
      Connection.Close();
  }
  </code></pre>
  
  <p>This throws an incorrect syntax error.  I've tried  moving the '%' to my parameter like so</p>
  
  <pre><code>Command.Parameters.Add(new SqlParameter("%name%", HolidayTextBox.Text));
  </code></pre>
  
  <p>but then I receive an error saying I haven't declared  the scalar variable '@name'.  So, how do you properly format wildcard characters to be included with query parameters?  Any help is appreciated!</p>