0

I have created one DataTable in C# dynamically. I want to insert this whole DataTable in MySql database table.

I am using MySql hence SqlBulkCopy is not an option for me. I have tried MySqlBulkLoader but it seems it only insert data from file.

I can do it via iterating through every datarow of datatable and insert it to database.

Is there any another way I can achieve multiple inserts into database?

Thanks for any help!

Pradip Prajapati
  • 152
  • 1
  • 4
  • 18

1 Answers1

0

If the number of rows are not much you can simply create an insert statement INSERT INTO table VALUES (1,2,3), (4,5,6), (7,8,9);

Another article at http://www.codeproject.com/Articles/19727/ADO-NET-Generic-Copy-Table-Data-Function may help.

Though, if the number of rows are high, you can probably create a temporary text file and then use BulkLoader !

Milind Thakkar
  • 980
  • 2
  • 13
  • 20