title: SQLite, Copy DataSet / DataTable to DataBase file
body: <p>I have filled a DataSet with a Table that was created from <strong>another</strong> database file.  The table is NOT in the database file which I want to be able to copy the Table to.  </p>
  
  <p>Now I want to save all those records (DataTable) to a newly created SQLite database file... </p>
  
  <p>How can i do that?</p>
  
  <p>Also I really want to avoid loops if this is possible.</p>
  
  <p>The best answer is by me :) so i'll share it.This is loop but writes 100k entries in 2-3secs.</p>
  
  <pre><code>using (DbTransaction dbTrans = kaupykliuduomConn.BeginTransaction())
  {
    downloadas.Visible = true; //my progressbar
    downloadas.Maximum = dataSet1.Tables["duomenys"].Rows.Count;
  
    using (DbCommand cmd = kaupykliuduomConn.CreateCommand())
    {
      cmd.CommandText = "INSERT INTO duomenys(Barkodas, Preke, kiekis) VALUES(?,?,?)";
      DbParameter Field1 = cmd.CreateParameter();
      DbParameter Field2 = cmd.CreateParameter();
      DbParameter Field3 = cmd.CreateParameter();
      cmd.Parameters.Add(Field1);
      cmd.Parameters.Add(Field2);
      cmd.Parameters.Add(Field3);
  
      while (n != dataSet1.Tables["duomenys"].Rows.Count)
      {
        Field1.Value = dataSet1.Tables["duomenys"].Rows[n]["Barkodas"].ToString();
        Field2.Value = dataSet1.Tables["duomenys"].Rows[n]["Preke"].ToString();
        Field3.Value = dataSet1.Tables["duomenys"].Rows[n]["kiekis"].ToString();
        downloadas.Value = n;
        n++;
        cmd.ExecuteNonQuery();
      }
    }
    dbTrans.Commit();
  }
  </code></pre>
  
  <p>In this case dataSet1.Tables["duomenys"] is already filled with all the data i need to transfer to another database. I used loop to fill dataset too.</p>