title: About reading multiple .dbf files in C#
body: <p>Currently I'm making a program to import values from multiple dBase files (.dbf). I have already an List full of Strings that have the name of the dBase files. That list is named <code>FicheirosParaAnalisar</code>. The dBase files not always have the same lines but they have all the same columns full of values that I want from one specific column named as <code>sigla_parametro</code>. The dBase filse are in <code>path9</code> My code by now is something like this:</p>
  
  <pre><code>private void button6_Click(object sender, EventArgs e)
      {
          ///*
  
          //Console.WriteLine(sigla_parametro);
          try
          {
              parametro = comboBox12.Text; //Console.WriteLine(parametro);
  
              for (int FA = 0; FA &lt; FicheirosParaAnalisar.Count; FA++)
              {
                  //Console.WriteLine(FicheirosParaAnalisar[FA]+".dbf");
  
                  if (importar == true)
                  {
                      //........................................................................
                      string connectionStringTotal = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path9 + ";Extended Properties=dBASE III;";
  
                      OleDbConnection connectionsTotal = new OleDbConnection(connectionStringTotal);
                      connectionsTotal.Open();
  
                      // Comando de aquisição dos dados da Base de Dados
                      string Comand_Strings_Total = "Select * From [" + FicheirosParaAnalisar[FA] + "]";
  
                      OleDbDataAdapter DataAdaptersTotal = new OleDbDataAdapter(Comand_Strings_Total, connectionsTotal);
                      DataSet datasetsTotal = new DataSet();
                      DataAdaptersTotal.Fill(datasetsTotal);
  
                      // Obter os valores dos parâmetros
                      int count = datasetsTotal.Tables[0].Rows.Count;
                      for (int i = 0; i &lt; count; i++)
                      {
                          try
                          {
                              valores_parametro.Add(FicheirosParaAnalisar[FA] + "_" + datasetsTotal.Tables[0].Rows[i][sigla_parametro].ToString());
                          }
                          catch (System.Data.OleDb.OleDbException exe)
                          {
                              string text = "[MPA5 - " + DateTime.Now.ToString() + "] Excepção encontrada: " + exe.Message + "\n";
                              System.IO.File.AppendAllText(log, text);
                          }
                          catch (Exception lolex)
                          {
                              string text = "[MPA5 - " + DateTime.Now.ToString() + "] Excepção encontrada: " + lolex.Message + "\n";
                              System.IO.File.AppendAllText(log, text);
                          }
                      }
                      count = 0;
                  }
                  Console.WriteLine("Ficheiro nº " + FA + " Importado!");
              }  
          }
          catch (Exception ex)
          {
              string text = "[MPA5 - " + DateTime.Now.ToString() + "] Excepção encontrada: " + ex.Message + "\n";
              System.IO.File.AppendAllText(log, text);
          }
  
          //*/
  
          valores_parametro.ForEach(Console.WriteLine);
  
          button1.Enabled = true;
      }
  </code></pre>
  
  <p>This code above only compute if I found all the dBase files (if so the variable <code>importar</code> becomes true). In theory I'm doing everything right, because the files exists and I have assigned every variable correctly, but really I have a problem in this code, because when I'm reading all the dBase files some files can't be read and an exception appear as I can see in my <code>LogFile.txt</code>. The message that appears is: </p>
  
  <pre><code>A first chance exception of type 'System.Data.OleDb.OleDbException' occurred in System.Data.dll
  </code></pre>
  
  <p>Now I want to ask you experts from Stackoverflow in C#, what I'm doing wrong? How can I get all the data from the column <code>sigla_parametro</code> to the List fo strings <code>valores_parametro</code>? How can I resolve my exception?</p>
  
  <p>Note:
  I've also tried to use this Connection String</p>
  
  <pre><code>string connectionStringTotal = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path9 + ";Extended Properties=dBASE IV;";
  </code></pre>
  
  <p>The string <code>path9</code> is the path to the folder that contains all my dBase files.</p>
  
  <pre><code>string path9 = "C:\\ProgramData\\CK electronic\\MPA5\\Data";
  </code></pre>
  
  <p>The List of strings <code>FicheirosParaAnalisar</code> has this strings:</p>
  
  <pre><code>CL-1831-150615-1
  CL-1831-150615-2
  CL-1831-150615-3
  CL-1831-150615-4
  CL-1831-150615-5
  CL-1832-150611-1
  CL-1832-150611-2
  CL-1832-150611-3
  CL-1832-150611-4
  CL-1832-150611-5
  CL-1833-150611-1
  CL-1833-150611-2
  CL-1833-150611-3
  CL-1833-150611-4
  CL-1833-150611-5
  CL-1834-150611-1
  CL-1834-150611-2
  CL-1834-150611-3
  CL-1834-150611-4
  CL-1834-150611-5
  CL-1835-150611-1
  CL-1835-150611-2
  CL-1835-150611-3
  CL-1835-150611-4
  CL-1835-150611-5
  CL-1836-150612-1
  CL-1836-150612-2
  CL-1836-150612-3
  CL-1836-150612-4
  CL-1836-150612-5
  CL-1837-150618-1
  CL-1837-150618-2
  CL-1837-150618-3
  CL-1837-150618-4
  CL-1837-150618-5
  CL-1838-150611-1
  CL-1838-150611-2
  CL-1838-150611-3
  CL-1838-150611-4
  CL-1838-150611-5
  CL-1839-150617-1
  CL-1839-150617-2
  CL-1839-150617-3
  CL-1839-150617-4
  CL-1839-150617-5
  CL-1840-150611-1
  CL-1840-150611-2
  CL-1840-150611-3
  CL-1840-150611-4
  CL-1840-150611-5
  CL-1841-150611-1
  CL-1841-150611-2
  CL-1841-150611-3
  CL-1841-150611-4
  CL-1841-150611-5
  CL-1842-150611-1
  CL-1842-150611-2
  CL-1842-150611-3
  CL-1842-150611-4
  CL-1842-150611-5
  CL-1843-150612-1
  CL-1843-150612-2
  CL-1843-150612-3
  CL-1843-150612-4
  CL-1843-150612-5
  CL-1844-150616-1
  CL-1844-150616-2
  CL-1844-150616-3
  CL-1844-150616-4
  CL-1844-150616-5
  CL-1844-150616-6
  CL-1845-150615-1
  CL-1845-150615-2
  CL-1845-150615-3
  CL-1845-150615-4
  CL-1845-150615-5
  CL-1846-150616-1
  CL-1846-150616-2
  CL-1846-150616-3
  CL-1846-150616-4
  CL-1847-150612-1
  CL-1847-150612-2
  CL-1847-150612-3
  CL-1847-150612-4
  CL-1847-150612-5
  CL-1848-150612-1
  CL-1848-150612-2
  CL-1848-150612-3
  CL-1848-150612-4
  CL-1848-150612-5
  CL-1850-150617-1
  CL-1850-150617-2
  CL-1850-150617-3
  CL-1850-150617-4
  CL-1850-150617-5
  CL-1851-150616-1
  CL-1851-150616-2
  CL-1851-150616-3
  CL-1851-150616-4
  CL-1851-150616-5
  CL-1852-150612-1
  CL-1852-150612-2
  CL-1852-150612-3
  CL-1852-150612-4
  CL-1852-150612-5
  CL-1853-150616-1
  CL-1853-150616-2
  CL-1853-150616-3
  CL-1853-150616-4
  CL-1853-150616-5
  CL-1854-150615-1
  CL-1854-150615-2
  CL-1854-150615-3
  CL-1854-150615-4
  CL-1854-150615-5
  CL-1855-150616-1
  CL-1855-150616-2
  CL-1855-150616-3
  CL-1855-150616-4
  CL-1855-150616-5
  CL-1856-150615-1
  CL-1856-150615-2
  CL-1856-150615-3
  CL-1856-150615-4
  CL-1856-150615-5
  CL-1857-150616-1
  CL-1857-150616-2
  CL-1857-150616-3
  CL-1857-150616-4
  CL-1857-150616-5
  CL-1858-150618-1
  CL-1858-150618-2
  CL-1858-150618-3
  CL-1858-150618-4
  CL-1858-150618-5
  CL-1860-150618-1
  CL-1860-150618-2
  CL-1860-150618-3
  CL-1860-150618-4
  CL-1860-150618-5
  CL-1861-150618-1
  CL-1861-150618-2
  CL-1861-150618-3
  CL-1861-150618-4
  CL-1861-150618-5
  CL-1862-150618-1
  CL-1862-150618-2
  CL-1862-150618-3
  CL-1862-150618-4
  CL-1862-150618-5
  CL-1863-150618-1
  CL-1863-150618-2
  CL-1863-150618-3
  CL-1863-150618-4
  CL-1863-150618-5
  </code></pre>
  
  <p>It is crucial to tell you that I have administrator permition to read and write data in the folder!</p>