共用方式為


SubscriberConnectionString 屬性

指定 SQL Server Compact 3.5 資料庫的連接字串。

命名空間:  System.Data.SqlServerCe
組件:  System.Data.SqlServerCe (在 System.Data.SqlServerCe.dll 中)

語法

'宣告
Public Property SubscriberConnectionString As String
    Get
    Set
'用途
Dim instance As SqlCeReplication
Dim value As String

value = instance.SubscriberConnectionString

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

屬性值

型別:System. . :: . .String
SQL Server Compact 3.5 資料庫的連接字串。

備註

這個屬性支援除 "persist security info" 以外的所有 ConnectionString 屬性。

使用 AddSubscription 方法建立新資料庫時,「地區設定識別碼」受到支援。請使用唯一的 LCID 做為地區設定識別項的值。若要尋找唯一的 LCID 值清單,請參閱《SQL Server Compact 3.5 線上叢書》中<SQL 參考>章節裡的「定序」主題。您必須確定要建立資料庫的裝置可支援該地區設定。

在指定 [SubscriberConnectionString] 的資料來源屬性時,您應該包含資料庫檔案的完整路徑,而非相對路徑。

範例

下列範例會設定 SqlCeReplication 物件的 SubscriberConnectionString 屬性。

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 命名空間