DtsProperty.GetValue(Object) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
返回属性的值。
public:
System::Object ^ GetValue(System::Object ^ o);
public object GetValue (object o);
member this.GetValue : obj -> obj
Public Function GetValue (o As Object) As Object
参数
- o
- Object
要返回其值的属性的父对象。
返回
包含属性的值的对象。
示例
using System;
using Microsoft.SqlServer.Dts.Runtime;
namespace DtsPropertyGetValueCS
{
class Program
{
static void Main(string[] args)
{
Package testPackage;
ConnectionManager testConnection;
DtsProperty testProperty;
string propertyValue;
testPackage = new Package();
testConnection = testPackage.Connections.Add("OLEDB");
testConnection.ConnectionString = "Provider=SQLOLEDB;" +
"Data Source=(local);Initial Catalog=AdventureWorks;" +
"Integrated Security=SSPI";
testConnection.Name = "Test Connection Manager";
testProperty = testConnection.Properties["ServerName"];
propertyValue = testProperty.GetValue(testConnection).ToString();
Console.WriteLine("The value of ServerName is: " + propertyValue);
Console.Read();
}
}
}
Imports Microsoft.SqlServer.Dts.Runtime
Module Module1
Sub Main()
Dim testPackage As Package
Dim testConnection As ConnectionManager
Dim testProperty As DtsProperty
Dim propertyValue As String
testPackage = New Package()
testConnection = testPackage.Connections.Add("OLEDB")
testConnection.ConnectionString = "Provider=SQLOLEDB;" & _
"Data Source=(local);Initial Catalog=AdventureWorks;" & _
"Integrated Security=SSPI"
testConnection.Name = "Test Connection Manager"
testProperty = testConnection.Properties("ServerName")
propertyValue = testProperty.GetValue(testConnection).ToString()
Console.WriteLine("The value of ServerName is: " & propertyValue)
Console.Read()
End Sub
End Module
注解
通过调用 GetValue 方法请求属性的值时,必须作为参数传递的对象是属性所属的对象。 例如,如果使用 OLE DB 连接管理器,如以下示例所示,并且已为其ServerName
属性创建了一个DtsProperty对象,则将连接管理器对象作为参数GetValue传递给该方法。