An open API service indexing awesome lists of open source software.

https://github.com/shalithacell/mysqlbulk-insert-update

Improve MySQL bulk data insert and update
https://github.com/shalithacell/mysqlbulk-insert-update

bulk bulk-data csharp mysql mysql-insert mysql-update

Last synced: 7 months ago
JSON representation

Improve MySQL bulk data insert and update

Awesome Lists containing this project

README

          

# MySQL BulkInsert & BulkUpdate
Fast way to insert and update a very large list of rows in My SQL using C#

Problem is that large list of data are insert and update operations in My SQL are very slow if you use SqlCommand in the one by one per data.

---

# Purpose

The purpose of this library is for performing Bulk Inserts and Updates without multiple insert and update statements for a collection of strongly typed queries.

---

# Usage

### Generating Data table
```C#
DataTable table = new DataTable();
table.Columns.Add("ID");
table.Columns.Add("Name");
for(int i = 0; i < 100; i++)
{
table.Rows.Add((i+1).ToString(), RandomString(10));
}
```

### Import lib

Add Reference to **MySQLBulkIU.dll** file

```C#
using MySQLBulkIU;
```

### Create connection string

```C#
string connectionString = "Server=localhost;Database=test;Uid=root;Pwd=1234;";
```

### Bulk Insert

```C#

//BulkToMySQL(DataTable dt, string tableName, string ConnectionString)
/* -------------------------key note----------------------------
*
* dt = datatable with values to be updated.
* tableName = Table name to be updated in Database.
* ConnectionString = MySql Connection String
*
* */
bool result = BulkInsert.BulkToMySQL(table, "test_bulk", connectionString);

if (result)
MessageBox.Show("Data Insert Successfully");
```

### Bulk Update

```C#
//UpdateBulkToMySQL(DataTable dt, string tableName, string valueColumn, string conditionColumn, string ConnectionString)
/* -------------------------key note----------------------------
*
* dt = datatable with values to be updated.
* tableName = Table name to be updated in Database.
* Value_Column = column name to be updated.
* conditionColumn = column name used to write 'WHERE' condition
* ConnectionString= MySQL connection string
* */

bool result = BulkUpdate.UpdateBulkToMySQL(table, "test_bulk", "Name", "ID", connectionString);

```

---

# Dependencies

* MySql.Data.dll

---

# Contribute

The best way to contribute is by spreading the word about the library:

* Blog it
* Comment it
* Fork it
* Star it
* Share it

A **HUGE THANKS** for your help.