다음을 통해 공유


SqlCeReplication.SaveProperties Method

현재 구독에 대해 SqlCeReplication 클래스 속성에 저장된 모든 값을 검색하여 시스템 테이블에 저장합니다.

네임스페이스: System.Data.SqlServerCe
어셈블리: System.Data.SqlServerCe(system.data.sqlserverce.dll에 있음)

구문

‘선언
Public Sub SaveProperties
public void SaveProperties ()
public:
void SaveProperties ()
public void SaveProperties ()
public function SaveProperties ()

주의

먼저 구독이 만들어져 있어야 동기화 속성을 저장할 수 있습니다. 동기화 실행에 필요한 모든 매개 변수가 제공되어야 SaveProperties를 정상적으로 호출할 수 있습니다. 동기화 속성을 저장할 때 선택적 매개 변수를 생략하게 되면 저장된 동기화 속성이 이미 존재하더라도 이러한 매개 변수에는 기본값이 설정됩니다. 속성을 덮어쓰지 않게 하려면 사용자는 우선 LoadProperties를 호출하여 동기화 속성을 검색하고 특정 속성을 변경한 다음 동기화 속성을 다시 저장해야 합니다.

SaveProperties가 호출되면 암호 속성의 값이 데이터베이스에 저장됩니다. 이러한 값은 고유한 장치 하드웨어 키를 사용하여 자동으로 암호화됩니다. 따라서 한 장치(또는 서버)에서 구독 프로필을 만든 다음 해당 데이터베이스를 새 장치로 복사하면 LoadProperties는 프로필에서 암호를 검색하지 못합니다. 정확한 암호를 직접 제공한 다음 SaveProperties를 다시 호출하여 해당 프로필이 새 장치에 남아 있도록 할 수 있습니다.

다음 예제에서는 SaveProperties 메서드를 사용하는 방법을 보여 줍니다.

Dim repl As SqlCeReplication = Nothing

Try
    ' Create SqlCeReplication instance
    '
    '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/sqlmobile/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"

    ' Store all the properties in the database
    '
    repl.SaveProperties()

    ' In the future all you need to do is load the properties
    '
    '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.SubscriberConnectionString = "Data Source='Test.sdf'; Pwd='<enterStrongPassword>'"
    repl.LoadProperties()

    ' Now the SqlCeReplication instance is ready to sync
    '
    repl.Synchronize()

Catch
    ' Handle errors here
Finally
    ' Dispose the repl object
    '
    repl.Dispose()
End Try
SqlCeReplication repl = null;

try
{
    // Create SqlCeReplication instance
    //
    //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/sqlmobile/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";

    // Store all the properties in the database
    //
    repl.SaveProperties();

    // In the future all you need to do is load the properties
    //
    //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.SubscriberConnectionString = "Data Source='Test.sdf'; Pwd='<enterStrongPassword>'";
    repl.LoadProperties();

    // Now the SqlCeReplication instance is ready to sync
    //
    repl.Synchronize();

}
catch (SqlCeException)
{
    // Handle errors here
}
finally
{
    // Dispose the repl object
    //
    repl.Dispose();
}

스레드 보안

이 유형의 모든 public static(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