LoadProperties メソッド

サーバーから既存のオブジェクトのプロパティを読み込みます。

名前空間:  Microsoft.SqlServer.Replication
アセンブリ:  Microsoft.SqlServer.Rmo (Microsoft.SqlServer.Rmo.dll)

構文

'宣言
Public Function LoadProperties As Boolean
'使用
Dim instance As ReplicationObject
Dim returnValue As Boolean

returnValue = instance.LoadProperties()
public bool LoadProperties()
public:
bool LoadProperties()
member LoadProperties : unit -> bool 
public function LoadProperties() : boolean

戻り値

型: System. . :: . .Boolean
Boolean 値です。true の場合、オブジェクトは MicrosoftSQL Server のインスタンスに存在します。false の場合、オブジェクトは SQL Server のインスタンスに存在しません。

説明

プロパティが既に読み込まれている場合、再度読み込まれることはありません。プロパティが最新ではない場合、オブジェクトで Refresh メソッドを呼び出して、最新の情報に更新します。

このオブジェクトに関する十分な情報がない場合は、例外が発生します。オブジェクトがサーバーに存在しない場合、メソッドは false を返します。オブジェクトがサーバーに存在する場合は、プロパティが読み込まれ、メソッドは true を返します。

この名前空間、クラス、またはメンバは、.NET Framework 2.0 でのみサポートされています。

使用例

           // Define the server, database, and publication names
            string publisherName = publisherInstance;
            string publicationName = "AdvWorksSalesOrdersMerge";
            string publicationDbName = "AdventureWorks";

            MergePublication publication;

            // Create a connection to the Publisher.
            ServerConnection conn = new ServerConnection(publisherName);

            try
            {
                // Connect to the Publisher.
                conn.Connect();

                // Set the required properties for the publication.
                publication = new MergePublication();
                publication.ConnectionContext = conn;
                publication.Name = publicationName;
                publication.DatabaseName = publicationDbName;


                // If we can't get the properties for this merge publication, then throw an application exception.
                if (publication.LoadProperties())
                {
                    // If DDL replication is currently enabled, disable it.
                    if (publication.ReplicateDdl == DdlReplicationOptions.All)
                    {
                        publication.ReplicateDdl = DdlReplicationOptions.None;
                    }
                    else
                    {
                        publication.ReplicateDdl = DdlReplicationOptions.All;
                    }
                }
                else
                {
                    throw new ApplicationException(String.Format(
                        "Settings could not be retrieved for the publication. " +
                        "Ensure that the publication {0} exists on {1}.",
                        publicationName, publisherName));
                }
            }
            catch (Exception ex)
            {
                // Do error handling here.
                throw new ApplicationException(
                    "The publication property could not be changed.", ex);
            }
            finally
            {
                conn.Disconnect();
            }
' Define the server, database, and publication names
Dim publisherName As String = publisherInstance
Dim publicationName As String = "AdvWorksSalesOrdersMerge"
Dim publicationDbName As String = "AdventureWorks"

Dim publication As MergePublication

' Create a connection to the Publisher.
Dim conn As ServerConnection = New ServerConnection(publisherName)

Try
    ' Connect to the Publisher.
    conn.Connect()

    ' Set the required properties for the publication.
    publication = New MergePublication()
    publication.ConnectionContext = conn
    publication.Name = publicationName
    publication.DatabaseName = publicationDbName

    ' If we can't get the properties for this merge publication, then throw an application exception.
    If publication.LoadProperties() Then
        ' If DDL replication is currently enabled, disable it.
        If publication.ReplicateDdl = DdlReplicationOptions.All Then
            publication.ReplicateDdl = DdlReplicationOptions.None
        Else
            publication.ReplicateDdl = DdlReplicationOptions.All
        End If
    Else
        Throw New ApplicationException(String.Format( _
         "Settings could not be retrieved for the publication. " + _
         "Ensure that the publication {0} exists on {1}.", _
         publicationName, publisherName))
    End If
Catch ex As Exception
    ' Do error handling here.
    Throw New ApplicationException( _
        "The publication property could not be changed.", ex)
Finally
    conn.Disconnect()
End Try