1

I know when using SQLBulkCopy we have to use close() after using it. So I set the code like below and then I didn't need to add bulkcopy.close()?

As I know, the using statement calls dispose() method but sqlbulk copy doesn't have a dispose method.

Although I didn't set the close() in the using statement, does it automatically call close?

using (var bulkCopy = new SqlBulkCopy(NotifyService.ConnectionStringForSqlBulkCopy, SqlBulkCopyOptions.FireTriggers | SqlBulkCopyOptions.UseInternalTransaction))
{
    ...
}
ItsPete
  • 2,363
  • 3
  • 27
  • 35
Oscar.Y
  • 15
  • 4
  • 1
    `Close` calls `Dispose` - https://referencesource.microsoft.com/#system.data/system/data/sqlclient/SqlBulkCopy.cs,789 The duplicate shows how the `Dispose` method is there using explicit interface implementation. – mjwills Sep 09 '19 at 02:00
  • then when I using the Using statement it call close() method automatically and close() call dispose() method? – Oscar.Y Sep 09 '19 at 02:41
  • No. `using` calls `Dispose`. – mjwills Sep 09 '19 at 02:55

0 Answers0