Freigeben über


DTSReadOnlyCollectionBase.Count Property

Gets the number of elements contained in the DTSReadOnlyCollectionBase instance.

Namespace: Microsoft.SqlServer.Dts.Runtime
Assembly : Microsoft.SqlServer.ManagedDTS (in microsoft.sqlserver.manageddts.dll)

Syntax

'Declaration
Public ReadOnly Property Count As Integer
public int Count { get; }
public:
virtual property int Count {
    int get () sealed;
}
/** @property */
public final int get_Count ()
public final function get Count () : int

Eigenschaftswert

An integer that contains the number of elements contained in the DTSReadOnlyCollectionBase instance.

Beispiel

The following code example shows how an inheriting class, the LogProviders collection, uses the Count property.

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Dts.Runtime;

namespace LogProviders_Tests
{
    class Program
    {
        static void Main(string[] args)
        {
            // The package is one of the SSIS Samples.
            string mySample = @"C:\Program Files\Microsoft SQL Server\90\Samples\Integration Services\Package Samples\ExecuteProcess Sample\ExecuteProcess\UsingExecuteProcess.dtsx";

            // Create the Application, and load the sample.
            Application app = new Application();
            Package pkg = app.LoadPackage(mySample, null);
            LogProviders logProvs = pkg.LogProviders;

            // Count the number of providers in the package.
            int countProvs = logProvs.Count;
            Console.WriteLine("Initial number of log providers: {0}", countProvs);

            // Since the package that was loaded only contained the
            // SSIS Log provider for Text files, let's add the SQL
            // Server log provider.
            LogProvider logProv = pkg.LogProviders.Add("DTS.LogProviderSQLServer.1");

            // Count how many log providers are in the collection now.
            countProvs = logProvs.Count;
            Console.WriteLine("The number of log providers now: {0}", countProvs);
            Console.WriteLine("----------------------------");

            foreach (LogProvider lp in logProvs)
            {
                Console.WriteLine("Log Provider Name: {0}", lp.Name);
            }
        }
    }
}
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.SqlServer.Dts.Runtime
 
Namespace LogProviders_Tests
    Class Program
        Shared  Sub Main(ByVal args() As String)
            ' The package is one of the SSIS Samples.
            Dim mySample As String =  "C:\Program Files\Microsoft SQL Server\90\Samples\Integration Services\Package Samples\ExecuteProcess Sample\ExecuteProcess\UsingExecuteProcess.dtsx" 
 
            ' Create the Application, and load the sample.
            Dim app As Application =  New Application() 
            Dim pkg As Package =  app.LoadPackage(mySample,Nothing) 
            Dim logProvs As LogProviders =  pkg.LogProviders 
 
            ' Count the number of providers in the package.
            Dim countProvs As Integer =  logProvs.Count 
            Console.WriteLine("Initial number of log providers: {0}", countProvs)
 
            ' Since the package that was loaded only contained the
            ' SSIS Log provider for Text files, let's add the SQL
            ' Server log provider.
            Dim logProv As LogProvider =  pkg.LogProviders.Add("DTS.LogProviderSQLServer.1") 
 
            ' Count how many log providers are in the collection now.
            countProvs = logProvs.Count
            Console.WriteLine("The number of log providers now: {0}", countProvs)
            Console.WriteLine("----------------------------")
 
            Dim lp As LogProvider
            For Each lp In logProvs
                Console.WriteLine("Log Provider Name: {0}", lp.Name)
            Next
        End Sub
    End Class
End Namespace

Sample Output:

Initial number of log providers: 1

The number of log providers now: 2

----------------------------

Log Provider Name: {FCA3ACD4-C080-4B67-A1AA-45118D3DA672}

Log Provider Name: SSIS log provider for Text files

Threadsicherheit

Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Plattformen

Entwicklungsplattformen

Eine Liste der unterstützten Plattformen finden Sie unterHardware- und Softwareanforderungen für die Installation von SQL Server 2005.

Zielplattforme

Eine Liste der unterstützten Plattformen finden Sie unterHardware- und Softwareanforderungen für die Installation von SQL Server 2005.

Siehe auch

Verweis

DTSReadOnlyCollectionBase Class
DTSReadOnlyCollectionBase Members
Microsoft.SqlServer.Dts.Runtime Namespace