title: how to read MS Access database in c# datatable
body: <p>I am trying to read a table from ms access using c#.net and want to store it in a datatable.</p>
  
  <p>when i display the Row from datatable in Combobox, it is not giving the required text.</p>
  
  <p>for eg: it is giving System.Data.DataRow instead of the actual value in the table.</p>
  
  <p>my code:</p>
  
  <pre><code>// Global Variables 
  
      OleDbConnection dbCon = new OleDbConnection();
      OleDbDataAdapter dbAdapter;
      DataTable localDT = new DataTable();
      int rowPos;
      int rowNum;
  
  private void ConnectToDb()
      {
          dbCon.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\CuttingParameters.mdb";
  
          try
          {
              dbCon.Open();
  
              dbAdapter = new OleDbDataAdapter("Select Distinct Material from CutParameters", dbCon);
  
              dbAdapter.Fill(localDT);
          }
          catch (Exception ex)
          {
              MessageBox.Show(ex.Message,"Error",MessageBoxButtons.OK);
          }
          if (localDT.Rows.Count != 0)
          {
              rowPos = localDT.Rows.Count;
          }
  
          textBox1.Text = rowPos.ToString();
      }
  
      private void FillMatCombo()
      {
          comboBox1.DataSource=localDT;
  
      }
  </code></pre>