在winform程序里的数据库使用了SQLite
当安装程序之后,在本地创建的SQLite数据库,随便就可以通过SQLite Database Browser之类的软件打开查看了。
不知道有什么方法可以让这个SQLite数据库不能随便被打开

解决方案 »

  1.   

    不明白你要做什么?
    我举个例子SQLServer的数据库你有办法让它不能随便打开吗?
      

  2.   


    需要连接到SQL的服务器,设置了登陆密码什么的还需要密码可是SQLite就是个文件
      

  3.   

    SQLite的数据库文件可以加密,不过官方那个提供加密的功能就不是免费的了
      

  4.   

    对 有些加密狗是可以加密dll的
      

  5.   

    可是SQLite就是个文件 错了这话,他不是文件,他只是一个DLL ,你如果想不打开可以加密呀,就是设置密码什么的
      

  6.   

    修改源代码
    http://liuleijsjx.javaeye.com/blog/424705
      

  7.   

    加密呀,sqlite可以加密的
     SQLiteConnectionStringBuilder builder = new SQLiteConnectionStringBuilder();
            SQLiteConnection Conn = new SQLiteConnection();
            string GetPath = @"...ConfigDB.s3db";
            /// <summary>
            /// 创建数据库密码
            /// </summary>
            public void SqliteCreate()
            {
                try
                {
                    builder.DataSource = GetPath;
                    Conn.ConnectionString = builder.ConnectionString;
                    if (Conn != null && Conn.State == ConnectionState.Closed)
                    { Conn.Open(); }
                    Conn.ChangePassword("123456");
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
      

  8.   

    楼上用到的应该是system.data.Sqlite.dll,用这个的话是带了加密功能的,所以楼主如果需要,可以直接下载那个,然后照楼上那样,给sqlite数据库加密。
      

  9.   


    可是这样出现了问题
    File opened that is not a database file
    file is encrypted or is not a database
      

  10.   

    在vs2008里建sqlite数据库的时候可以设置密码的啊  。
    好像还要装SQLite-1.0.65.0-setup.exe这个东西吧
      

  11.   

    一旦用了密码,连接这边就提示个错误:File opened that is not a database file
    file is encrypted or is not a database
      

  12.   

     string record = "";
                using (System.Data.SQLite.SQLiteConnection cnn = new System.Data.SQLite.SQLiteConnection())
                {
                    using (System.Data.SQLite.SQLiteCommand cmd = new System.Data.SQLite.SQLiteCommand())
                    {
                        string cnnstr = @"data source=E:\sql.db;Version=3;Password=aaaa;";
                        cnn.ConnectionString = cnnstr;
                        if (cnn.State != ConnectionState.Open)
                            cnn.Open();
                        cmd.CommandText = "Select * from TB1";
                        cmd.Connection = cnn;
                        System.Data.SQLite.SQLiteDataReader rd = cmd.ExecuteReader();                    while (rd.Read())
                        {
                            if (record.Length > 0)
                                record += "\r\n";
                            record += (rd[0] is DBNull) ? string.Empty : rd[0].ToString();
                            record += (rd[1] is DBNull) ? string.Empty : "\t" + rd[1].ToString();
                        }
                    }
                }
                if (record.Length > 0)
                    MessageBox.Show(record);
    机密的sqlite没有啊,使用的是system.data.sqlite.dll 。
      

  13.   

    写错字了,还有一个词居然没打上来,“机密的sqlite没有啊”————应该是“加密的sqlite没有问题啊”
    在csdn上发帖后居然没有权限修改,奇哉
      

  14.   

    csdn只能连续顶三楼,发帖作者也没有修改帖子的权限,只有重新注册一个马甲来补充问题了:源代码在这里有,如果觉得有疑问,你可以下载看看,那个sqlite数据库我是安装了SQLite-1.0.65.0-setup.exe后,使用vs2008创建的,加了密码的,然后在代码里连接读出数据,就这样而已:
    下载地址:
    http://www.sudupan.com/down.aspx?id=130613其实代码也就19楼那个,为了方便你,我把测试项目打包了。
      

  15.   

    1、system.data.sqlite 支持加密;
    2、生成的经过加密的数据库目前很少有免费管理软件可以打开和操作。
    3、推荐一款支持密码的免费管理软件:SQLite2009Pro(我找了好久才找到),该软件界面非常友好,功能强大。
      

  16.   

    system.data.sqlite有使用密码的功能。conn是SQLiteConnection 类的对象,则第一次使用时先open数据库文件,
    然后使用
    conn.ChangePassword("密码");
    设置数据库文件的密码。(changepassword方法必须在open之后才可以用)
    以后打开数据库文件的时候,要先使用
    conn.SetPassword("密码");
    来输入数据库文件的秘密,然后才可以打开。(setpassword方法必须在open之前使用)
    楼主你第二次打开数据库文件依然使用changepassword当然会报错
    File opened that is not a database file
    file is encrypted or is not a database
    changepassword是没有密码,设置密码,或者改变密码时用的,必须先open才可以。