次の方法で共有


PublisherAddress プロパティ

パブリッシャへの接続時に使用するネットワーク アドレスを指定します。

名前空間:  System.Data.SqlServerCe
アセンブリ:  System.Data.SqlServerCe (System.Data.SqlServerCe.dll)

構文

'宣言
Public Property PublisherAddress As String
    Get
    Set
'使用
Dim instance As SqlCeReplication
Dim value As String

value = instance.PublisherAddress

instance.PublisherAddress = value
public string PublisherAddress { get; set; }
public:
property String^ PublisherAddress {
    String^ get ();
    void set (String^ value);
}
member PublisherAddress : string with get, set
function get PublisherAddress () : String
function set PublisherAddress (value : String)

プロパティ値

型: System. . :: . .String
パブリッシャへの接続時に使用するネットワーク アドレス。

説明

PublisherAddress は、PublisherNetwork に DefaultNetwork 以外の値が設定されている場合は必須です。

このプロパティで、SQL Server Replication Provider がパブリッシャと通信する方法を指定します。たとえば、SQL Server Compact 3.5 レプリケーション エージェントとパブリッシャが 2 つの異なるシステム上にあり、システム間の通信にインターネットが使用される場合は、PublisherNetwork を TcpIpSockets に、PublisherAddress を特定の IP アドレスに設定できます。

PublisherNetwork の値を TcpIpSockets または MultiProtocol に設定している場合、PublisherAddress の値は、"IP address,port number" の形式 (たとえば、"111.11.11.11,1433") になります。

使用例

SqlCeReplication オブジェクトの PublisherAddress プロパティを設定する例を次に示します。

Dim repl As SqlCeReplication = Nothing

Try
    ' Instantiate and configure SqlCeReplication object
    '
    'NOTE: when possible, prompt users to enter security 
    'credentials at runtime. If you store credentials in a file, 
    'you must secure the file to prevent unauthorized access.
    '
    repl = New SqlCeReplication()
    repl.InternetUrl = "https://www.adventure-works.com/sqlce/sqlcesa35.dll"
    repl.InternetLogin = "MyInternetLogin"
    repl.InternetPassword = "<enterStrongPassword>"
    repl.Publisher = "MyPublisher"
    repl.PublisherDatabase = "MyPublisherDatabase"
    repl.PublisherLogin = "MyPublisherLogin"
    repl.PublisherPassword = "<enterStrongPassword>"
    repl.Publication = "MyPublication"
    repl.Subscriber = "MySubscriber"
    repl.SubscriberConnectionString = "Data Source=MyDatabase.sdf"

    ' Create the local SQL Mobile Database subscription
    '
    repl.AddSubscription(AddOption.CreateDatabase)

    ' Synchronize to the SQL Server to populate the Subscription 
    '
    repl.Synchronize()
Catch
    ' Handle errors here
    '
Finally
    ' Dispose the repl object
    '
    repl.Dispose()
End Try
SqlCeReplication repl = null;

try
{
    // Instantiate and configure SqlCeReplication object
    //
    //NOTE: when possible, prompt users to enter security 
    //credentials at runtime. If you store credentials in a file, 
    //you must secure the file to prevent unauthorized access.
    //
    repl = new SqlCeReplication();
    repl.InternetUrl = "https://www.adventure-works.com/sqlce/sqlcesa35.dll";
    repl.InternetLogin = "MyInternetLogin";
    repl.InternetPassword = "<enterStrongPassword>";
    repl.Publisher = "MyPublisher";
    repl.PublisherDatabase = "MyPublisherDatabase";
    repl.PublisherLogin = "MyPublisherLogin";
    repl.PublisherPassword = "<enterStrongPassword>";
    repl.Publication = "MyPublication";
    repl.Subscriber = "MySubscriber";
    repl.SubscriberConnectionString = "Data Source=MyDatabase.sdf";

    // Create a local SQL Mobile Database subscription
    //
    repl.AddSubscription(AddOption.CreateDatabase);

    // Synchronize to the SQL Server database
    //
    repl.Synchronize();
}
catch (SqlCeException)
{
    // Handle errors here
    //
}
finally
{
    // Dispose the repl object
    //
    repl.Dispose();
}

関連項目

参照

SqlCeReplication クラス

SqlCeReplication メンバー

System.Data.SqlServerCe 名前空間