Answered by:
Setting password on new sdf

Question
-
When the sync framework creates a new sdf on the local machine, how can I tell it to set a password on the sdf as well? Maybe this can be done after the sdf is created with a SQL statement?
- Moved by Liam Cavanagh - MSFTMicrosoft employee Thursday, January 21, 2010 7:40 PM (From:SyncFx - Microsoft Sync Framework Database Providers)
Friday, January 8, 2010 8:26 PM
Answers
-
The first assumption might be correct (I am not sure) and the second assumption is absolutely correct.
I am simply adding a "Local Database Cache" to my C# library in Visual Studio, then following the wizard to set it up. To cause a sync, I am only calling a few lines of code that I barely understand (but they work): I am simply calling SyncAgent.Synchronize().
However, my problem of setting the password just magically fixed itself! I added a password to the connect string in App.Config and the next time I created a new sdf from scratch, it just magically created it with that password. It was an accident, really. It just happened.
I LOVE the Sync Framework. Having worked with SQL for decades, and having dealt with synchronization issues using old car batteries and fishing line ... this stuff just blows my mind. I have developed a very complex WPF application that is currently in production with users synchronizing data to a centrally hosted 2K8 server all day every day without the first problem. Tons of foreign key constraints and everything. Just amazing.
Thanks for the quick response!- Marked as answer by Sean_Kelley Wednesday, January 13, 2010 6:25 AM
Saturday, January 9, 2010 3:11 AM
All replies
-
Can you please provide more detail about the method you are using to create the SDF file?
Friday, January 8, 2010 9:43 PMAnswerer -
I am going to make a couple assumptions so let me know if these are incorrect:
· You are using SqlCeClientSyncProvider
· The .sdf file is being created as a part of the initialization process that downloads schema info as well as the initial data
If these assumptions are correct, you can use the OnSchemaCreated or CreatingSchema events to password protect the file before or after the schema has been created. If the assumptions above are incorrect (i.e. you are using SqlCeSyncProvider instead), my answer is going to differ slightly.
Regards,
Sean Kelley
Senior Program Manager
MicrosoftFriday, January 8, 2010 9:58 PM -
The first assumption might be correct (I am not sure) and the second assumption is absolutely correct.
I am simply adding a "Local Database Cache" to my C# library in Visual Studio, then following the wizard to set it up. To cause a sync, I am only calling a few lines of code that I barely understand (but they work): I am simply calling SyncAgent.Synchronize().
However, my problem of setting the password just magically fixed itself! I added a password to the connect string in App.Config and the next time I created a new sdf from scratch, it just magically created it with that password. It was an accident, really. It just happened.
I LOVE the Sync Framework. Having worked with SQL for decades, and having dealt with synchronization issues using old car batteries and fishing line ... this stuff just blows my mind. I have developed a very complex WPF application that is currently in production with users synchronizing data to a centrally hosted 2K8 server all day every day without the first problem. Tons of foreign key constraints and everything. Just amazing.
Thanks for the quick response!- Marked as answer by Sean_Kelley Wednesday, January 13, 2010 6:25 AM
Saturday, January 9, 2010 3:11 AM