I am using normal INSERT
queries to write a DataTable
into my database. This way I know which record is being inserted and I can tell my ProgressBar
to show the progress percentage correctly. But I would like to replace my record-by-record INSERTs with one bulk copy because it is apparently much faster.
When I look at the bulk copy code, the main copy part is done via the function
WriteToServer()
. I was wondering if there is a way to notify my progress bar about the percentage. I do not need to now the percentage when every record is being inserted. I have set my program to show progress by each 500 records. I would like my progress bar to still be able to show the percentage and not a simple marquee that says "in progress...". Is there a way to do that?
Asked
Active
Viewed 1,092 times
0

disasterkid
- 6,948
- 25
- 94
- 179
-
2Use [`NotifyAfter`](http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy.notifyafter%28v=vs.110%29.aspx) – Matthew Watson Oct 09 '14 at 07:44
-
2In addition to @MatthewWatson answer you should subscribe to [SqlRowsCopied](http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy.sqlrowscopied.aspx) event to get notified how much rows was proccessed at the moment. – Ivan Zub Oct 09 '14 at 07:46
-
Possible duplicate of [I need progressbar with SQLBulkcopy](https://stackoverflow.com/questions/38131088/i-need-progressbar-with-sqlbulkcopy) – A Jar of Clay Sep 16 '19 at 15:16