title: How to create an Access database using C# and continuously save real-time data to it
body: <p><strong>I am currently in the process of making an application that runs 24/7 and constantly collects information from an OPC-sever.</strong> </p>
  
  <p>What I need to do now is to send this information to a database (<em>.accdb-file</em>). This need to happen very, very quickly. I fetch a new value from the server every millisecond and I need to send that value to the database at the same speed. Lastly I'm compressing the database to a .zip-file at 00:00 every day.</p>
  
  <p>I have been searching the web like a maniac but I can't seem to find an "Up-to-date" tutorial. Every one I have found so far uses "<em>Microsoft.Jet.OLEDB.4.0</em>" as provider but it doesn't exsist on my Windows 7 PC.</p>
  
  <p>I have made a small application to test connections with and I'll attach my current code bellow to give you a hint of what I have tried so far, none of this seems to work, though.</p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e)
  {
      System.Reflection.Assembly oAssembly = System.Reflection.Assembly.GetExecutingAssembly();
      System.IO.Stream oStream = oAssembly.GetManifestResourceStream("RSLogixDB.accdb");
      System.IO.FileStream fileStream = new System.IO.FileStream("C:\\Users\\sezettersth\\Documents\\RSLogixDB.accdb", System.IO.FileMode.Create);
  
      byte[] abyt = new byte[oStream.Length];
      oStream.Read(abyt, 0, (int)oStream.Length);
      fileStream.Write(abyt, 0, (int)oStream.Length);
      fileStream.Close();
      if (fileStream != null)
      {
          fileStream.Close();
          fileStream = null;
      }
      if (oStream != null)
      {
          oStream = null;
      }
  }
  </code></pre>
  
  <p>This is the first approach I tried, here I use a homemade class that is used for creating and writing to files. It didn't work for .accdb-files, unfotunately. (The comments on the first lines include providers that I have tried.</p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e)
  {
      //sFileDia.ShowDialog();
      //Provider=Microsoft.ACE.OLEDB.12.0
      //Povider=.NET Framework Data Provider for OLE DB
      //Povider=Microsoft.Jet.OLEDB.4.0
      //Driver={Microsoft Access Driver (*.mdb, *.accdb)};
      //Data Source=C:\\Users\\sezettersth\\Documents\\RSLogixDB.accdb;
      //Persist Security Info=False;
      //Provider=Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\sezettersth\\Documents\\RSLogixDB.accdb;Persist Security Info=False
      string RSLogixDB = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\sezettersth\\Documents\\RSLogixDB.accdb;Persist Security Info=False";
      string RSLogixDBPath = "C:\\Users\\sezettersth\\Documents\\RSLogixDB.accdb";
      OleDbConnection connection = new OleDbConnection(RSLogixDB);
      string connectionStr = connection.ConnectionString;
  
      //OleDbDataReader dataReader = new OleDbDataReader(RSLogixDB);
      ImportExport textwriter = new ImportExport();
      textwriter.setExportPath(RSLogixDBPath);
      textwriter.endExport();
  }
  </code></pre>
  
  <p>There has to be a simple solution to this, I can't be the only one using Access without the "<em>Microsoft.Jet.OLEDB.4.0</em>" provider. </p>
  
  <p>(I haven't started the code for zipping the file and if you have an idea on how to do that I'm happy to hear it, but the main focus here is the database issue.)</p>
  
  <p><strong>UPDATE: The problem might not lie on the provider as I initially though, Microsoft.ACE.OLEDB.12.0 allows me to create a .accdb-file but it is just an empty txt-file with a fancy extension basically and it cannot be opened or used with MS Access. How do I make a working .accdb-file?</strong></p>