views:

295

answers:

1

Hello,

I am working with SQL Server and I want to set the Database password of a SQL Server CE Database (*.sdf). I found the Command how I can create a new database with password:

CREATE DATABASE "secure.sdf"
DATABASEPASSWORD '<enterStrongPasswordHere>'

But I want to set a password of an existing db.

+2  A: 

You need to use the Compact API of SqlCeEngine API

http://msdn.microsoft.com/en-us/library/system.data.sqlserverce.sqlceengine.compact(VS.80).aspx

SqlCeEngine engine = new SqlCeEngine("Data Source = db.sdf");
engine.Compact(null);
engine.Compact("Data Source=; Password =pass;");
Amgad Fahmi