How to combine in MySQL using C #

Earlier, I used the SQLBulkCopy class to load data into an MS SQL Server database. The results were very good and worked exactly as I intended.

Now I'm trying to use a script task in SSIS to load large amounts of data into a MySQL database (5.5.8) using either an ODBC connection or ADO.NET (recommended?).

The columns in my dataset correspond to the columns of the MySQL table. What is the best way to do bulk insert dataset into MySQL database?

+5
source share
1 answer

You can use the MySqlBulkLoader that ships with the MySQL Connector for .NET:

var bl = new MySqlBulkLoader(connection);
bl.TableName = "mytable";
bl.FieldTerminator = ",";
bl.LineTerminator = "\r\n";
bl.FileName = "myfileformytable.csv";
bl.NumberOfLinesToSkip = 1;
var inserted = bl.Load();
Debug.Print(inserted + " rows inserted.");
+13
source

All Articles