How to connect to sqlite database with password

前端 未结 3 2068
没有蜡笔的小新
没有蜡笔的小新 2021-02-07 10:25

I have a sqlite database and I want to connect from my C# program using a password for the database. I am using Navicat and I set encrypt database file with password \"test\" an

3条回答
  •  日久生厌
    2021-02-07 10:44

    Its very long time ago, but here is my solution that work's with LITEDB using connectionstring and password. But remember you need to set password in your db first. You can use this tool (LITE DB EXPLORER ) to create and manage your databases. https://github.com/JosefNemec/LiteDbExplorer

    In App Config Add your connection string like this example:

    
        
              
                
          
             
                
            
        
    

    And in C# code behind:

    private static string LoadConnectionString(string id = "LiteDB")
        {
            try { 
                return ConfigurationManager.ConnectionStrings[id].ConnectionString + ";password=your_pass";
            }
            catch (Exception loadConnectionStringError)
            {
                Console.WriteLine("loadConnectionStringError: " + loadConnectionStringError.ToString());
                return null;
            }
        }
    

提交回复
热议问题