dda*_*lis 13 c# sqlite navicat
我有一个sqlite数据库,我想使用数据库的密码从我的C#程序连接.我正在使用Navicat,我用密码"test"设置加密数据库文件,然后通过代码我的连接字符串是:
_connection = new SQLiteConnection("Data Source=MedExpress.db;Version=3;Password=\"test\";");
Run Code Online (Sandbox Code Playgroud)
要么
_connection = new SQLiteConnection("Data Source=MedExpress.db;Version=3;Password=test;");
Run Code Online (Sandbox Code Playgroud)
但这不起作用.
错误是: File opened that is not a database file
file is encrypted or is not a database
我可以没有像这样的密码连接到数据库:
_connection = new SQLiteConnection("Data Source=MedExpress.db;Version=3;");
Run Code Online (Sandbox Code Playgroud)
我的问题是如何设置sqlite数据库的密码并使用C#程序连接 System.Data.SQLite
Pri*_*Jea 16
这是带密码的连接字符串
Data Source=filename;Version=3;Password=myPassword;
Run Code Online (Sandbox Code Playgroud)
如您所述,您使用navicat设置sqlite加密.加密意味着您已经加密了数据库,这与将密码设置为数据库不同.
在设置数据库的密码时尝试此代码..
//create file
SQLite.SQLiteConnection.CreateFile("c:\\mydatabase file.db3")
Dim cn As New SQLite.SQLiteConnection
//set password
cn.ChangePassword("paxword")
//remove password
cn.ChangePassword("")
Run Code Online (Sandbox Code Playgroud)
首先删除加密..
你可以通过连接字符串提供密码;
Data Source = filename; Version = 3; Password = myPassword;
另外,看看他的链接
希望能帮助到你