SqlBulkCopy::NotifyAfter Property

 

Defines the number of rows to be processed before generating a notification event.

Namespace:   System.Data.SqlClient
Assembly:  System.Data (in System.Data.dll)

public:
property int NotifyAfter {
	int get();
	void set(int value);
}

Property Value

Type: System::Int32

The integer value of the NotifyAfter property, or zero if the property has not been set.

This property is designed for user interface components that illustrate the progress of a bulk copy operation. It indicates the number of rows to be processed before generating a notification event. The NotifyAfter property can be set at any time, even while a bulk copy operation is underway. Changes made during a bulk copy operation take effect after the next notification. The new setting applies to all subsequent operations on the same instance.

If NotifyAfter is set to a number less than zero, an ArgumentOutOfRangeException is thrown.

The following console application demonstrates how to bulk load data using a connection that is already open. The NotifyAfter property is set so that the event handler is called after every 50 rows copied to the table.

In this example, the connection is first used to read data from a SQL Server table to a SqlDataReader instance. Then a second connection is opened to bulk copy the data. Note that the source data does not have to be located on SQL Server; you can use any data source that can be read to an IDataReader or loaded to a DataTable.

System_CAPS_importantImportant

This sample will not run unless you have created the work tables as described in Bulk Copy Example Setup. This code is provided to demonstrate the syntax for using SqlBulkCopy only. If the source and destination tables are in the same SQL Server instance, it is easier and faster to use a Transact-SQL INSERT … SELECT statement to copy the data.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0
Return to top
Show: