0

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://learn.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 Provider

StackTrace:
at System.Data.SqlServerCe.SqlCeEngine.Repair(SEFIXOPTION option, String dstConnStr, RepairOption repairOption)

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
dan
  • 801
  • 15
  • 41

1 Answers1

0

Hmmm OK it is working now.

var updatePasswordConnStr = "DataSource=; password=newPass;";
dan
  • 801
  • 15
  • 41