title: Char encoding and SQL in C#
body: <p>I have this sql:</p>
  <blockquote>
  <p>select productid from products where productcode = @code</p>
  </blockquote>
  <p>and @code is a parameter, it's value was <code>ABCÊ</code> but it matched <code>ABC</code> debugging it in visual studio showed � in the quickwatch. the database has <code>Latin1_General_CI_AS</code> as collation. The field type in the database is an nvarchar(50)</p>
  <p>So why is the datarow containing productcode = 'ABC' returned when I compare it to <code>ABCÊ</code>?
  I entered this in my smss <code>select 1 where 'ABC' = 'ABCÊ'</code> and it did not return 1, this did: select 1 where 'ABC' = 'ABC'
  So is it in my code? something with utf or encoding?</p>
  <p><strong>edit</strong> c# code:</p>
  <pre><code>SqlCommand comGetProd = new SqlCommand(@&quot;SELECT ProductID FROM PRODUCTS WHERE (ProductCode = @name)&quot;);
  comGetProd.Parameters.AddWithValue(&quot;name&quot;, &quot;ABCÊ&quot;);
  </code></pre>
  <p><strong>edit 15-6-2015</strong></p>
  <p>narrowed the problem down as @Oskar Sjöberg suggested. It is not database related! Because this returns <code>true</code>:</p>
  <pre><code>using (StreamReader sr = new StreamReader(&quot;test.csv&quot;))
  {
      while (!sr.EndOfStream)
      {                  
          Console.WriteLine(&quot;D1103SL&quot;.Equals(sr.ReadLine()));
      }
  }
  </code></pre>
  <p>test.csv contains: <code>D1103SLÊ</code></p>
  <p><img src="https://i.stack.imgur.com/TG06J.png" alt="enter image description here" /></p>
  <p>notepad++:</p>
  <p><img src="https://i.stack.imgur.com/UeHNq.png" alt="enter image description here" /></p>
  <p>so it is <a href="http://www.codetable.net/hex/ca" rel="nofollow noreferrer">http://www.codetable.net/hex/ca</a> I still do not see how it is equal.</p>