Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Improve MySQL bulk data insert and update

NotificationsYou must be signed in to change notification settings

ShalithaCell/MySQLBulk-Insert-Update

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

DataTabletable=newDataTable();table.Columns.Add("ID");table.Columns.Add("Name");for(inti=0;i<100;i++){table.Rows.Add((i+1).ToString(),RandomString(10));}

Import lib

Add Reference toMySQLBulkIU.dll file

usingMySQLBulkIU;

Create connection string

stringconnectionString="Server=localhost;Database=test;Uid=root;Pwd=1234;";

Bulk Insert

//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             *             * */boolresult=BulkInsert.BulkToMySQL(table,"test_bulk",connectionString);if(result)MessageBox.Show("Data Insert Successfully");

Bulk Update

//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             * */boolresult=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

AHUGE THANKS for your help.

About

Improve MySQL bulk data insert and update

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp