title: Save SQL DataSet to Local MDB File
body: <p><em>Context</em></p>
  
  <p>My appliction uses an SQL database from which it reads my datatables at start of my application. If the application would fail to connect to the SQL DB, I have a local Ms Access .MDB file. I have a separate thread that checks if the local database is outdated.</p>
  
  <p>I have a DataTable which I obtain from my SQL connection --> Verified and working
  I can connect to my Access database locally and read from it --> Verified and working</p>
  
  <p><em>Issue/Question</em></p>
  
  <p>I'm trying to update my local database by updating it with the DataTable I obtained from my SQL Connection. </p>
  
  <pre><code>public static void UpdateLocalDatabase(string strTableName, OleDbConnection MyConnection, DataTable MyTable)
  {
      try
      {
          if (CreateDatabaseConnection() != null)
          {
              string strQuery = "SELECT * FROM " + strTableName;
              OleDbDataAdapter MyAdapter = new OleDbDataAdapter();
              OleDbCommandBuilder MyCommandBuilder = new OleDbCommandBuilder(MyAdapter);
              MyAdapter.SelectCommand = new OleDbCommand(strQuery, odcConnection);
              MyAdapter.UpdateCommand = MyCommandBuilder.GetUpdateCommand();
              MyConn.Open();
              MyAdapter.Update(MyTable);
              MyConn.Close();
          }
      }
      catch { }
  }
  </code></pre>
  
  <p>If I debug this snippet, all variables are what they should be:</p>
  
  <ul>
  <li>strTableName = the correct name for my table</li>
  <li>MyConn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=MyLocation;Persist Security Info=True;JET OLEDB:Database Password=MyPassword;"</li>
  <li>MyTable = is the correct table that is also used further on by my application</li>
  </ul>
  
  <p>This process runs through without an error and without using the catch but it does not touch my database, it just doesn't do a thing.</p>
  
  <p>Am I dropping the ball here or just missing the obvious, I have no idea but I browsed many articles and apart for showing the MyAdapter.Update(), there doesn't seem to be much more to it.</p>
  
  <p>Any help is welcome.</p>
  
  <p>Thanks,</p>
  
  <p>Kevin</p>