title: How can I export GridView to MS Access in C#
body: <p>I want to export grid to MS Access in C#</p>
  
  <p>Here's the code that I've tried:</p>
  
  <pre><code>String accessConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=C:\\...\\test.accdb;"; 
  String sqlConnectionString = ConfigurationManager.ConnectionStrings["College"].ConnectionString; 
  SqlDataAdapter adapter1 = new SqlDataAdapter(); 
  adapter1.Fill(dtFillGrid); 
  ADOX.Catalog catalog = new ADOX.Catalog(); 
  catalog.Create(accessConnectionString); 
  OleDbConnection accessConnection = new OleDbConnection(accessConnectionString);
  OleDbCommand command = new OleDbCommand(); 
  command.Connection = accessConnection; 
  command.CommandType = CommandType.Text; 
  accessConnection.Open(); 
  foreach (DataTable table in dtFillGrid.Rows) { 
      String columnsCommandText = "(";
      foreach (DataColumn column in table.Columns) { 
          String columnName = column.ColumnName; 
          String dataTypeName = column.DataType.Name; 
          String sqlDataTypeName = getSqlDataTypeName(dataTypeName); 
          columnsCommandText += "[" + columnName + "] " + sqlDataTypeName + ","; 
      }   
      columnsCommandText = columnsCommandText.Remove(columnsCommandText.Length - 1);   
      columnsCommandText += ")";
      command.CommandText = "CREATE TABLE " + table.TableName + columnsCommandText; 
      command.ExecuteNonQuery(); 
  }
  //This loop fills the database with all information 
  foreach (DataTable table in dtFillGrid.Rows) { 
      foreach (DataRow row in table.Rows) { 
          String commandText = "INSERT INTO " + table.TableName + " VALUES (";
          foreach (var item in row.ItemArray) { 
              commandText += "'" + item.ToString() + "',";
          } 
          commandText = commandText.Remove(commandText.Length - 1); 
          commandText += ")"; 
          command.CommandText = commandText; command.ExecuteNonQuery(); 
      } 
  } 
  accessConnection.Close(); 
  </code></pre>
  
  <p>How can I do this?</p>