1

I have an encrypted database using "SQLite Cipher". When I try to connect to the database using Connection string the following error message appears:

'SQL logic error Cannot use "Password" connection string property: library was not built with encryption support.'

Code With Error

Imports System.Data.SQLite
Public Class frm_projects
    Dim dtset As New SQLiteConnection("Data Source=Setting.db;Password=m;")

    Private Sub frm_projects_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Try
            If dtset.State = ConnectionState.Closed Then
                dtset.Open()

            End If
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information, "Warning")
        End Try
    End Sub
End Class

Image From DB Browser sqlite Cipher

10
  • Are we allowed to see your code where you're creating the connection? Commented Jun 28, 2020 at 0:31
  • Dim dtset As New SQLiteConnection("Data Source=Setting.db;Password=m;") Try If dtset.State = ConnectionState.Closed Then dtset.Open() MsgBox("Connection Success!", MsgBoxStyle.Information, "Informations") 'list_projects.Items.Add("ANa") End If Catch ex As Exception MsgBox("Failed to connect to SQLite Database", MsgBoxStyle.Information, "Warning") End Try Commented Jun 28, 2020 at 0:36
  • imgur.com/a/6TUVKRI Commented Jun 28, 2020 at 0:37
  • stackoverflow.com/a/41426738/10216583 Commented Jun 28, 2020 at 1:20
  • 2
    Check your connection string. What is Data Source=Setting.db ? This should be the path of the database. Maybe you mean: Dim dtset As New SQLiteConnection($"Data Source={My.Settings.db};Password=m;") where db is a string property in your Application settings. Commented Jun 28, 2020 at 17:17

2 Answers 2

2

Source of the issue

I assume that the actual reason for this error is the the lack of support in "legacy CryptoAPI" since System.Data.SQLite version ~1.0.113.1.

It was done in the following commit: https://system.data.sqlite.org/index.html/info/1dd56c9fd59a10fd

What can we do?

  1. Manually Use the last NuGet version with CryptoAPI support - 1.0.112.2.

    Notice - It must be done manually - either by editing PackageReference in csproj or by editing config.packages. the reason is that older versions are unlisted (!) from the NuGet feed: NuGet feed only shows ONE version

  2. Buy perpetual source code license for SQLite Encryption Extension (SEE) which costs one time fee of 2000$ (as of Feb 2021) - purchase link

  3. Use SQLCipher - SQLCipher is an SQLite extension that provides 256 bit AES encryption of database files - GitHub source (haven't tested it myself!)

Data Sources

Sign up to request clarification or add additional context in comments.

Comments

1

Change System.data.sqlite by this package Link

To set a password to an unprotected database:

Dim conn = New SQLite.SQLiteConnection(
    "Data Source=C:\yourFolder\yourDB.db3;Version=3;")
conn.Open()
conn.ChangePassword("password")
conn.Close()

To open a password-protected database:

Dim conn = New SQLite.SQLiteConnection(
    "Data Source=C:\yourFolder\yourDB.db3;Version=3;")
conn.SetPassword("password")
conn.Open()
conn.Close()

or

Dim conn = New SQLite.SQLiteConnection(
    "Data Source=C:\yourFolder\yourDB.db3;Version=3;Password=password;")
conn.Open()
conn.Close()

To remove password from a password-protected database:

Dim conn = New SQLite.SQLiteConnection(
    "Data Source=C:\yourFolder\yourDB.db3;Version=3;Password=password;")
conn.Open()
conn.ChangePassword(String.Empty)
conn.Close()

Note: The open source database manager SQLiteStudio is able to open files which were password-protected that way, as long as you choose System.Data.SQLite instead of Sqlite 3 as your database type. (Requires v 3.1.1, the current version).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.