//1.给不带密码的数据库添加密码
string strconn = @"Data Source=E:\test.db3;Pooling=true;FailIfMissing=false";
sqliteConnection conn = new sqliteConnection(strconn);
conn.Open();
//首次设置密码
conn.ChangePassword("password");
conn.Close();
//2.读取带密码的数据
string strconn = @"Data Source=E:\test.db3;Pooling=true;FailIfMissing=false";
sqliteConnection conn = new sqliteConnection(strconn);
//输入密码
conn.SetPassword("password");
string sql = "select * from tb";
sqliteDataAdapter adapter = new sqliteDataAdapter(sql,conn);
DataSet ds = new DataSet();
adapter.Fill(ds);
this.dataGridView1.DataSource = ds.Tables[0];
//3.修改数据库密码 string strconn = @"Data Source=E:\test.db3;Pooling=true;FailIfMissing=false"; sqliteConnection conn = new sqliteConnection(strconn); //数据原来密码 conn.SetPassword("old_password"); conn.Open(); //设置新密码 conn.ChangePassword("new_password"); conn.Close();