I think you need to set that value right after you instantiate the object and before you call the WriteToServer Method:
using (SqlConnection conn = new SqlConnection(ConnectionString))
{
conn.Open();
using (SqlBulkCopy sqlcpy = new SqlBulkCopy(conn))
{
sqlcpy.SqlRowsCopied += new SqlRowsCopiedEventHandler(OnSqlRowsCopied); //<<---- You need to add this here
sqlcpy.NotifyAfter = 1;
sqlcpy.BatchSize = batchSize;
sqlcpy.BulkCopyTimeout = 60;
using (SqlCommand cmd = new SqlCommand(Sql, conn))
{
cmd.ExecuteNonQuery();
sqlcpy.DestinationTableName = TableName; //copy the datatable to the sql table
sqlcpy.WriteToServer(dt);
return sqlcpy.GetRowsCopied();
}
}
}
and it goes without saying but you also need a OnSqlRowsCopied event handler:
private static void OnSqlRowsCopied(object sender, SqlRowsCopiedEventArgs e)
{
Console.WriteLine("Copied {0} so far...", e.RowsCopied);
}