title: How to import MDB file, read and save in SQL
body: <p>I need to import .MDB file, read and save in SQL Server. 
  I tried this:</p>
  
  <h2><strong>Method Import</strong></h2>
  
  <pre><code>protected void Btn_Importar(object sender, EventArgs e)
  {
      if (FileUpload1.HasFile)
          {
              if (FileUpload1.PostedFile.ContentType == "application/msaccess")
              {
                      string filename = Path.GetFileName(FileUpload1.FileName);
                      FileUpload1.SaveAs(Server.MapPath("~/Upload/") + filename);
                      Label1.Text = "File uploaded successfully!";
                      //ReadMdb();
                      Insert();
              }
      }
  }
  </code></pre>
  
  <h2><strong>Method Insert</strong></h2>
  
  <pre><code>public void Insert()
  {
          string strFile = Server.MapPath("~/Upload/teste.mdb");
          string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strFile;
          var myDataTable = new DataTable();
          using (var connection = new OleDbConnection("Provider=Microsoft.JET.OLEDB.4.0;" + "data source=" + strFile))
          {
              connection.Open();
                  var query = "SELECT * FROM BOLETO";
                  var command = new OleDbCommand(query, connection);
                  var reader = command.ExecuteReader();
  
                  Conexaocs con = new Conexaocs();
                  con.Conexao();
  
                  SqlCommand sqlComm = new SqlCommand("INSERT INTO BOLETO (CODIGO,NF_CONTA,TEXTO) VALUES (@CODIGO, @NF_CONTA, @TEXTO)", conn);
  
                  //if (reader.HasRows)
                  //{
                  //    while (reader.Read())
                  //    {
                  //        //ListBox1.Items.Add(reader.GetInt32(0).ToString() + " - " + reader.GetString(1));
                  //    }
  
                  for (int i = 0; i &lt; reader.FieldCount; i++)
                  {
                      sqlComm.Parameters.AddWithValue("@CODIGO", reader[i]);
                          sqlComm.Parameters.AddWithValue("@NF_CONTA", reader[i]);
                          sqlComm.Parameters.AddWithValue("@TEXTO", reader[i]);
                          sqlComm.ExecuteNonQuery();
                  }
  
                  connection.Close();
          }
  }
  </code></pre>
  
  <hr>
  
  <p>But, when come this point not save!</p>
  
  <pre><code>for (int i = 0; i &lt; reader.FieldCount; i++)
  {
     sqlComm.Parameters.AddWithValue("@CODIGO", reader[i]);
     sqlComm.Parameters.AddWithValue("@NF_CONTA", reader[i]);
     sqlComm.Parameters.AddWithValue("@TEXTO", reader[i]);
     sqlComm.ExecuteNonQuery();
  
  }
  </code></pre>
  
  <p><strong>Message error:</strong> <em>System.InvalidOperationException: There are no data for the row or column</em>
  <img src="https://i.stack.imgur.com/SZL0J.jpg" alt="enter image description here"></p>
  
  <p>Some idea? Thanks </p>