SqlCeReplication.SaveProperties Method
Consente di recuperare tutti i valori memorizzati nelle proprietà della classe SqlCeReplication per la sottoscrizione corrente e di memorizzarle in una tabella di sistema.
Spazio dei nomi: System.Data.SqlServerCe
Assembly: System.Data.SqlServerCe (in system.data.sqlserverce.dll)
Sintassi
'Dichiarazione
Public Sub SaveProperties
public void SaveProperties ()
public:
void SaveProperties ()
public void SaveProperties ()
public function SaveProperties ()
Osservazioni
Prima di salvare le proprietà di sincronizzazione, è necessario aver creato correttamente una sottoscrizione; affinché la chiamata al metodo SaveProperties abbia esito positivo, è necessario fornire tutti i parametri obbligatori per l'esecuzione della sincronizzazione. Se i parametri non obbligatori vengono omessi durante il salvataggio delle proprietà di sincronizzazione, verranno impostati sui relativi valori predefiniti, anche se sono già presenti proprietà di sincronizzazione salvate. Per evitare la sovrascrittura delle proprietà, prima è necessario recuperare le proprietà di sincronizzazione mediante la chiamata a LoadProperties, modificare le particolari proprietà e quindi salvare nuovamente le proprietà di sincronizzazione.
Quando viene chiamato il metodo SaveProperties, i valori delle proprietà della password vengono memorizzati nel database. Questi valori vengono crittografati automaticamente con la chiave hardware univoca di dispositivo. Se pertanto si crea un profilo di sottoscrizione su un dispositivo, o server, e quindi si copia il database su un nuovo dispositivo, LoadProperties non riuscirà a recuperare la password dal profilo. È possibile fornire la password corretta manualmente e quindi chiamare di nuovo il metodo SaveProperties per mantenere il profilo sul nuovo dispositivo.
Esempio
Nell'esempio riportato di seguito viene illustrato come utilizzare il metodo 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();
}
Affidabilità
Tutti i membri statici pubblici (Shared in Microsoft Visual Basic) di questo tipo sono affidabili. Non è invece garantita l'affidabilità dei membri dell'istanza.
Piattaforme
Piattaforme di sviluppo
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
Informazioni sulla versione
.NET Framework e .NET Compact Framework
Supportato in 3.5
.NET Framework
Supportato in 3.0
.NET Compact Framework e .NET Framework
Supportato in 2.0
Vedere anche
Riferimento
SqlCeReplication Class
SqlCeReplication Members
System.Data.SqlServerCe Namespace