简体   繁体   中英

How to attach sqlite Unencrypted database to an encrypted one

Please need a help...i want to attach an unencrypted sqlite database to another encrypted one, I am using DevExpress XpoDefault.Session to do that..but I always get error message "File is encrypter or not a database".

string conStr = string.Format( "XpoProvider=SQLite;Data Source={0};Password=1234", MyEncryptedDbFile );

MyDatalayer = XpoDefault.GetDataLayer(conStr, AutoCreateOption.DatabaseAndSchema);

string s = Path.Combine(Application.StartupPath, MyUnEncryptedDbFile);
XpoDefault.Session = new UnitOfWork(MyDataLayer);
string st = string.Format("attach database '{0}' as AttachedAlias", s);
XpoDefault.Session.ExecuteNonQuery(st); /// Error File is encrypted or not database.....*

Best regards, and excuse my english

I find a way to do this, but is it the Best...??

first Open the encrypted One;

XpoDefault.Session = new UnitOfWork(MyDataLayer);

second Change the password to Empty and attach the unencrypted database :

SQLiteConnection connection = XpoDefault.Session.Connection as SQLiteConnection;
connection.ChangePassword(string.Empty);
string st = string.Format("attach database '{0}' as AttachedAlias", s);
XpoDefault.Session.ExecuteNonQuery(st);

and finally restore the password of encrypted database

connnection.ChangePassword("1234");

it work ...but is it the best way ?...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM