title: like statement for npgsql using parameter
body: <p>I have a postgresql DB and i want to query the table "Locations" to retrieve the names of all the locations that match the name that's entered by the user. The column name is "LocationName". I'm using ASP.net with C#.</p>
  
  <pre><code>NpgsqlConnection con = new NpgsqlConnection(ConfigurationManager.ConnectionStrings["ConnString"].ToString());
  
  NpgsqlCommand cmd = new NpgsqlCommand("Select * from \"Locations\" where \"LocationName\" LIKE \"%@loc_name%\"", con);
  
  cmd.Parameters.AddWithValue("@loc_name", Location_Name);
  
  NpgsqlDataReader reader = cmd.ExecuteReader();
  </code></pre>
  
  <p>I get this exception:</p>
  
  <pre><code>Npgsql.NpgsqlException: ERROR: 42703: column &amp;quot;%((E'My place'))%&amp;quot; does not exist
  </code></pre>
  
  <p>I've tried running the query without using %, but it doesn't work.
  I've also tried using + and &amp; like given below but that didn't work either:</p>
  
  <pre><code>string query = "Select \"LocationName\" from \"Locations\" where \"LocationName\" LIKE '%'+ :loc_name +'%'";
  </code></pre>
  
  <p>with the above line, i get this exception:</p>
  
  <pre><code>Npgsql.NpgsqlException: ERROR: 42725: operator is not unique: unknown + unknown
  </code></pre>