title: Using 'SUBSTRING(expression, startIndex, length)' with BindingSource on DataColumn
body: <p>I am trying to filter a numeric string by matching the start of the source string and the length of the search string.</p>
  
  <p>All the filtered columns are strings. Most are just words, but there is one column that has values that look like this <code>001302:Alt#</code>. The underlying data source sucks, but I cannot change the structure. The numbers are grouped based on the left-hand values (i.e. <code>050110</code> and <code>050534</code> are both related to client(05), <code>052123</code> is related to client(05) invoices(2)). My users want to be able to search the data in the DataGridView and filter that column by group (i.e. Enter 05 and see everything that starts with 05, or 052 and see 052000-052999)</p>
  
  <p>I am generating the filter string and setting the Filter property on the BindingSource using the DataSet as DataSource and the Table as DataMember. The rest of my filtering works, the only problem I am having is with the numeric filter. When I set the <code>BindingSource.Filter</code> property, it throws an <code>ArgumentOutOfRange</code> exception.</p>
  
  <blockquote>
    <p>An unhandled exception of type 'System.ArgumentOutOfRangeException'
    occurred in System.Data.dll Additional information: Substring()
    argument is out of range.</p>
  </blockquote>
  
  <p>I thought I might be firing this against an empty row, or one that only had a few digits, but it is firing with only one character. Therefore, the length argument should be valid, but it is still throwing the exception. </p>
  
  <pre><code>bool firstColumn = true;
  foreach (DataColumn column in FilteredColumns.Keys)
  {
      if (FilteredColumns[column])
      {
          if (!firstColumn) fieldFilter.Append(") OR ("); else firstColumn = false;
  
          int numericFilter;
          if (int.TryParse(filterWord, out numericFilter))
          {
              fieldFilter.Append(String.Format("SUBSTRING({0}, 0, {2}) = {1}", column.ColumnName, filterWord, filterWord.Length));
          }
          else
              {
              fieldFilter.Append(String.Format("{0} like '%{1}%'", column.ColumnName, filterWord));
              }
      }
  }
  </code></pre>
  
  <p>I am sure I am just missing something stupid. I thank you in advance for pointing out my error(s)!</p>