Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set password of an existing sql ce database (per Code)

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.

like image 735
Gepro Avatar asked Mar 04 '10 08:03

Gepro


1 Answers

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;");
like image 68
Amgad Fahmi Avatar answered Nov 24 '22 10:11

Amgad Fahmi