Set the password of an existing sql ce database (for each code)

I work with SQL Server and I want to set the password for the SQL Server CE database database (* .sdf). I found a command, how can I create a new database with a password:

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

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

+4
source share
1 answer

You need to use the SqlCeEngine Compact API 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;"); 
+10
source

Source: https://habr.com/ru/post/1303095/


All Articles