Use of MySQLLoader witha DataSet

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply

Use of MySQLLoader witha DataSet

Post by nuntio2000 » Thu 18 Nov 2004 08:43

how can I use MySQLLoader to INSERT a dataset into the database?
Could you write same code lines for sample please ?

Devart Team
Posts: 264
Joined: Thu 28 Oct 2004 13:56

Re: Use of MySQLLoader witha DataSet

Post by Oleg » Thu 18 Nov 2004 13:26

You can load data from DataSet into MySQL database using the next code sample:

Code: Select all

/// Tables must be created before you call this function
/// if you have InnoDB table, set this parameter = false
void CopyDataSet(DataSet dataset, string connectionString, bool delayed) {

  MySqlConnection connection = new MySqlConnection(connectionString);

  MySqlLoader loader = new MySqlLoader();
  loader.Connection = connection;
  loader.Delayed = delayed;

  foreach (DataTable table in dataSet.Tables) {
    loader.TableName = table.TableName;

    foreach (DataRow row in table.Rows) {
      for (int i = 0; i < table.Columns.Count; ++i)
        loader.SetValue( i, row[i]);
    loader.Close(); // flush table to database

Posts: 19
Joined: Fri 19 Nov 2004 18:51
Location: South Italy


Post by nuntio2000 » Sat 20 Nov 2004 10:14

It works perctly!!

Post Reply