Best way to Bulk Insert from a C# DataTable

后端 未结 5 669
轻奢々
轻奢々 2020-12-01 09:29

I have a DataTable that I want to push to the DB. I want to be able to say like

myDataTable.update();

But after reading the M

5条回答
  •  感情败类
    2020-12-01 10:13

    If using SQL Server, SqlBulkCopy.WriteToServer(DataTable)

    • SqlBulkCopy.WriteToServer Method (DataTable)

    Or also with SQL Server, you can write it to a .csv and use BULK INSERT

    • BULK INSERT (Transact-SQL)

    If using MySQL, you could write it to a .csv and use LOAD DATA INFILE

    • LOAD DATA INFILE Syntax

    If using Oracle, you can use the array binding feature of ODP.NET

    • Bulk Insert to Oracle using .NET

    If SQLite:

    • How do I bulk insert with SQLite?
    • Faster bulk inserts in sqlite3?

提交回复
热议问题