DTSReadOnlyCollectionBase.Count 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取 DTSReadOnlyCollectionBase 实例中包含的元素数。
public:
property int Count { int get(); };
public int Count { get; }
member this.Count : int
Public ReadOnly Property Count As Integer
属性值
一个整数,该整数包含包括在 DTSReadOnlyCollectionBase 实例中的元素数。
实现
示例
下面的代码示例演示继承类( LogProviders 集合)如何使用 Count 该属性。
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\100\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\100\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
示例输出:
日志提供程序的初始数目:1
现在的日志提供程序数:2
----------------------------
日志提供程序名称:{FCA3ACD4-C080-4B67-A1AA-45118D3DA672}
日志提供程序名称:文本文件的 SSIS 日志提供程序