title: Cannot get char_length() function to work in an Access query
body: <p>I have a database with a lot of words and I am trying to get the last word of certain character length. I have a method for it called getWord() that returns a string for me. For this certain code I am using 5 as the character length that I'm trying to filter. I am no expert in SQL but I tried researching on how to do this and I came across the char_length() function. So i tried using it. However, when I run my program, it does not do anything. Here is my code. BTW, I am using C#.</p>
  
  <p>I would be really grateful for any kind of help. Thanks</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  
  using System.Data.OleDb;
  
  namespace take2
  {
      class MainGameControl
      {
          private OleDbConnection connection = new OleDbConnection();
  
          public MainGameControl()
          {
              connection.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\RJ\c#\take2  - updated\Take2.accdb;Persist Security Info=False;";
          }
  
          public string getWord()
          {
              string word = "";
              connection.Open();
              OleDbCommand command = new OleDbCommand();
              command.Connection = connection;
              command.CommandText = "SELECT Words FROM Dictionary WHERE CHAR_LENGTH(Words) = 5 Order by Words DESC;";
              OleDbDataReader reads = command.ExecuteReader();    
  
              if (reads.Read())
              {
                  word = reads.GetString(0);            
              }
              connection.Close();
              return word;
          }        
      }
  }
  </code></pre>