Bulk insert C# complex objects into SQL Server Table using SqlBulkCopy (Code)

preview_player
Показать описание
This video illustrates how we can write C# code to bulk insert user defined objects into a SQL Server Table using SqlBulkCopy class objects.

Following steps are followed to achieve this.
1. Get a DataTable from list of records
2. Create SqlBulkCopy object with a SQL connection to connect to the database
3. Use SqlBulkCopy method WriteToServer to insert into a database table

Credits:
Music : YouTube Audio Library
Database Technology: SQL Server
IDE : Visual Studio 2019
Рекомендации по теме
Комментарии
Автор

Thank you very much for this. Not sure whether it is Google watching me all the time or some other serendipitous power that made this pop up on YouTube today when I actually just wanted to check the news. And it made the point that I was missing last night very clear. I'm really grateful!

NelCapeTown
Автор

perfect. Thank you very much for this.

mmizarela
Автор

Sir, how about inserting around 10, 000 to 50, 000+ records or even million of records, can i use this bulk Insert to improve the performance? ( Anyone who see this comment, can advise me also, thanks and appreciated!) .

J
Автор

cl.DataType = prop.PropertyType; doesn't support nullable properties.
What's the solution?

shifattest