title: Obtaining the Maximum Field Size of an Access Column
body: <p>Hi all you Stack Overflowers. I am having bit of a dilemma here. I need to obtain the Maximum of characters you may enter into a field but I have had no success and Google did not produce anyhing similar to what I need</p>
  
  <p>Here is my Code</p>
  
  <pre><code>            lvwDestination.Columns.Add("Fields in Database", 150, HorizontalAlignment.Left);
  
              lvwDestination.Columns.Add("DataType", 100, HorizontalAlignment.Left);
  
              lvwDestination.Columns.Add("Max", 100, HorizontalAlignment.Left);
  
              for (int i = 0; i &lt; DataTable.Columns.Count; i++)
              {
  
                  _lvwItem = new ListViewItem(DataTable.Columns[i].ColumnName, 0);
  
                  _lvwItem.Name = DataTable.Columns[i].ColumnName;
  
                  _lvwItem.SubItems.Add(DataTable.Columns[i].DataType.Name.ToString());
  
                 _lvwItem.SubItems.Add(DataTable.Columns[i].MaxLength.ToString());
                  lvwDestination.Items.AddRange(new ListViewItem[] { _lvwItem });
  
  
              }
  </code></pre>
  
  <p>Now as you can see I have tried </p>
  
  <pre><code>_lvwItem.SubItems.Add(DataTable.Columns[i].MaxLength.ToString());
  </code></pre>
  
  <p>but the only thing that this came up with is -1 for every column. I have also made sure that my columns do in fact have the property field size attribute on. The .ColumnName and .DataType works perfectly but .MaxLength produces -1 always.
  Thanks in advance for anyone that might be able to come up with a solution.</p>