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

1

5

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.

Runkel answered 4/3, 2010 at 8:15 Comment(0)
P
9

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;");
Pippas answered 4/3, 2010 at 8:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.