Using SQL Server CE 4.0.8876.1 (NuGet package). I'm trying to change the password of an existing SQL Server CE database as per this article: https://docs.microsoft.com/en-us/previous-versions/sql/compact/sql-ce-3.0/reference/kt1a3805(v=vs.85)?redirectedfrom=MSDN
Perhaps I cannot change the password if the existing database is already encrypted?
var oldConnStr = "DataSource=\"C:\\temp\\FilePath.sdf\";Persist Security Info=False;
password=oldPass; Encrypt Database=True; flush interval=1";
var updatePasswordConnStr = "DataSource=; password=newPass; Encrypt Database=True;";
using (var sqlCeEngine = new SqlCeEngine(oldConnStr))
{
sqlCeEngine.Compact(null);
sqlCeEngine.Compact(updatePasswordConnStr);
}
I keep getting the following exception when I call sqlCeEngine.Compact
(both calls):
System.Data.SqlServerCe.SqlCeException
HResult=0x80004005
Message=The password specified for the source database is incorrect. [ Data Source = FilePath.sdf ]
Source=SQL Server Compact ADO.NET Data ProviderStackTrace:
at System.Data.SqlServerCe.SqlCeEngine.Repair(SEFIXOPTION option, String dstConnStr, RepairOption repairOption)
Hmmm OK it is working now.
var updatePasswordConnStr = "DataSource=; password=newPass;";
User contributions licensed under CC BY-SA 3.0