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: about 1 year ago
JSON representation
Improve MySQL bulk data insert and update
- Host: GitHub
- URL: https://github.com/ShalithaCell/MySQLBulk-Insert-Update
- Owner: ShalithaCell
- Created: 2019-03-06T03:16:28.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-09T04:36:45.000Z (about 7 years ago)
- Last Synced: 2025-04-23T00:28:31.556Z (about 1 year ago)
- Topics: bulk, bulk-data, csharp, mysql, mysql-insert, mysql-update
- Language: C#
- Size: 230 KB
- Stars: 7
- Watchers: 0
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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.