欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C#連接加密的Sqlite數(shù)據(jù)庫(kù)的方法

 更新時(shí)間:2017年08月03日 13:48:46   作者:LittleFeiHu  
對(duì)數(shù)據(jù)加密分兩種,一種是對(duì)數(shù)據(jù)庫(kù)本身進(jìn)行加密,另一種是對(duì)數(shù)據(jù)表中的數(shù)據(jù)進(jìn)行加密,下面通過(guò)本文給大家介紹C#連接加密的Sqlite數(shù)據(jù)庫(kù)的方法,感興趣的朋友一起看看吧

對(duì)數(shù)據(jù)加密分兩種,一種是對(duì)數(shù)據(jù)庫(kù)本身進(jìn)行加密,另一種是對(duì)數(shù)據(jù)表中的數(shù)據(jù)進(jìn)行加密,

如果SQLite數(shù)據(jù)庫(kù)加密,我這里使用的一個(gè)管理工具叫SQLiteDeveloper,如下就可以加密數(shù)據(jù)庫(kù)

,

如果在工具中不提供密碼的情況下打開數(shù)據(jù)庫(kù),會(huì)給你錯(cuò)誤提示如下:

,

或者在C# 使用錯(cuò)誤的密碼也會(huì)給你錯(cuò)誤提示:

System.Data.SQLite.SQLiteException:“file is encrypted or is not a database

,

 正確的連接方式就是在連接字符串中提供正確的密碼:

using System;
using System.Collections.Generic;
using System.Data.SQLite;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OpenSqliteDBByPwd
{
  class Program
  {
    static void Main(string[] args)
    {
      string DB_PATH = "Data Source=EncryptedDB.db3; Password=1111";
      using (SQLiteConnection con = new SQLiteConnection(DB_PATH))
      {
        con.Open();
        string sqlStr = @"INSERT INTO Customer(CUST_NO,CUSTOMER)
                 VALUES
                 (
                   3001,
                   'Allen'
                 )";
        using (SQLiteCommand cmd = new SQLiteCommand(sqlStr, con))
        {
          cmd.ExecuteNonQuery();
        }
      }
    }
  }
}

總結(jié)

以上所述是小編給大家介紹的C#連接加密的Sqlite數(shù)據(jù)庫(kù)的方法,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評(píng)論