SqlCeReplication.SubscriberConnectionString 属性

指定到 SQL Server Compact Edition 数据库的连接字符串。

命名空间: System.Data.SqlServerCe
程序集: System.Data.SqlServerCe(在 system.data.sqlserverce.dll 中)

语法

声明
Public Property SubscriberConnectionString As String
用法
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);
}
/** @property */
public String get_SubscriberConnectionString ()

/** @property */
public void set_SubscriberConnectionString (String value)
public function get SubscriberConnectionString () : String

public function set SubscriberConnectionString (value : String)
不适用。

属性值

到 SQL Server Compact Edition 数据库的连接字符串。

备注

除“持久性安全信息”外,此属性支持所有其他 ConnectionString 属性。

如果使用 AddSubscription 方法创建新数据库,则支持区域设置标识符值。请用 Unique LCID 表示区域设置标识符的值。若要查找 Unique LCID 值的列表,请参见 SQL Server Compact Edition Books Online(《SQL Server Compact Edition 联机丛书》)的“SQL Reference”(SQL 参考)一节中“Collate”(逐份打印)这一主题。必须确保创建数据库的设备支持该区域设置。

指定 SubscriberConnectionString 的数据源属性时,应使用数据库文件的完整路径,而非相对路径。

示例

下面的示例设置 SqlCeReplication 对象的 SubscriberConnectionString 属性。

Dim repl As SqlCeReplication = Nothing

Try
    ' Instantiate and configure SqlCeReplication object
    '
    repl = New SqlCeReplication()
    repl.InternetUrl = "https://www.adventure-works.com/sqlmobile/sqlcesa30.dll"
    repl.InternetLogin = "MyInternetLogin"
    repl.InternetPassword = "<password>"
    repl.Publisher = "MyPublisher"
    repl.PublisherDatabase = "MyPublisherDatabase"
    repl.PublisherLogin = "MyPublisherLogin"
    repl.PublisherPassword = "<password>"
    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
    //
    repl = new SqlCeReplication();
    repl.InternetUrl = "https://www.adventure-works.com/sqlmobile/sqlcesa30.dll";
    repl.InternetLogin = "MyInternetLogin";
    repl.InternetPassword = "<password>";
    repl.Publisher = "MyPublisher";
    repl.PublisherDatabase = "MyPublisherDatabase";
    repl.PublisherLogin = "MyPublisherLogin";
    repl.PublisherPassword = "<password>";
    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();
}

平台

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

Windows Vista、Microsoft Windows XP SP2 和 Windows Server 2003 SP1 支持 Microsoft .NET Framework 3.0。

版本信息

.NET Framework

受以下版本支持:3.0

.NET Compact Framework

受以下版本支持:2.0、1.0

请参见

参考

SqlCeReplication 类
SqlCeReplication 成员
System.Data.SqlServerCe 命名空间