title: Perform a case-sensitive sql query with StrComp funtion for MS Access in c#
body: <p>I am new to C#. I tried to write a case-sensitive sql query for Microsoft Access in C#.
  Here is part of the table named &quot;EmployeeList&quot;. Notice the second record has a lower case for &quot;s&quot;:</p>
  <pre><code>| ID   | Name      | InternalID |
  |:----:|:---------:| :---------:|
  | 8    | John Smith| 52455      |
  | 9    | John smith| 49         |
  | ...  | ...       | ...        |
  </code></pre>
  <p>Here is the query. I tested in Access, and it worked well.</p>
  <pre><code>SELECT InternalID FROM EmployeeList WHERE StrComp(Name, 'John Smith', 0) = 0;
  </code></pre>
  <p>What is the correct syntax to write it in C#? I have looked up many sources but my code is still wrong:</p>
  <pre><code>public DataTable findInternalID(string name)
          {
              Connection.Open();
              DataTable output = new DataTable();
              OleDbCommand bdCommand = RecordConnection.CreateCommand() as OleDbCommand;
              
              StringBuilder x = new StringBuilder();
              x.AppendLine(&quot;SELECT InternalID &quot;);
              x.AppendLine(&quot;FROM EmployeeList &quot;);
              x.AppendLine($&quot;WHERE StrComp(Name, @name, 0) = 0&quot;);
            
              bdCommand.CommandText = x.ToString();
              bdCommand.Parameters.AddWithValue(&quot;name&quot;, $&quot;%{name}%&quot;);
  
              _dataAdapter = new OleDbDataAdapter(bdCommand);
              _dataAdapter.Fill(output);
  
              RecordConnection.Close();
              return output;
  
          }
  </code></pre>
  <p>and here is the code under main to test my function:</p>
  <pre><code>string name = &quot;John Smith&quot;;
  DataTable output = _accessManager.findInternalID(name);
  String message;
  message = output.Rows[0][0].ToString();
  MessageBox.Show(message);
  </code></pre>
  <p>and this code throws me an error:</p>
  <blockquote>
  <p>System.IndexOutOfRangeException: 'There is no row at position 0.'</p>
  </blockquote>
  <p>Why there's no record written into result?</p>