共用方式為


SqlCeReplication.PublisherAddress Property

指定連接至發行者時使用的網路位址。

命名空間: System.Data.SqlServerCe
組件: System.Data.SqlServerCe (在 system.data.sqlserverce.dll)

語法

'宣告
Public Property PublisherAddress As String
public string PublisherAddress { get; set; }
public:
property String^ PublisherAddress {
    String^ get ();
    void set (String^ value);
}
/** @property */
public String get_PublisherAddress ()

/** @property */
public void set_PublisherAddress (String value)
public function get PublisherAddress () : String

public function set PublisherAddress (value : String)

屬性值

連接至發行者時使用的網路位址。

備註

只有當 PublisherNetwork 設定為 DefaultNetwork 以外的值時,才需要 PublisherAddress 屬性。

指定這個屬性,可指示 SQL Server 複寫提供者如何與發行者通訊。例如,如果 SQL Server Compact 3.5「複寫代理程式」和「發行者」位於兩個不同的系統,且這兩個系統都是透過網際網路通訊,則 PublisherNetwork 可以設定為 TcpIpSockets,而 PublisherAddress 可以設定為特定的 IP 位址。

如果 PublisherNetwork 值是設定為 TcpIpSocketsMultiProtocol,則 PublisherAddress 值會採用「IP 位址,通訊埠編號」的格式 (例如,'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();
}

執行緒安全性

任何公用靜態 (共用 在 Microsoft Visual Basic) 此型別的成員具備執行緒安全。不保證任何執行個體成員安全執行緒。

平台

開發平台

Windows Vista, Windows Mobile 5.0, Windows XP Professional with Service Pack 2 (SP2), Windows Server 2003, Windows Mobile 2003 for Pocket PC, Windows CE 5.0
版本資訊
.NET Framework 及 NET Compact Framework
支援於 3.5
.NET Framework
支援於 3.0
.NET Compact Framework 及 .Net Framework
支援於 2.0

另請參閱

參考

SqlCeReplication Class
SqlCeReplication Members
System.Data.SqlServerCe Namespace