4

I'm implementing SQLite functionality in my code, where I can create an SQLite database file and communicate with it. I can't, however, password protect it. I've seen a lot of solutions, for example:

conn = new SQLiteConnection(connectionString);
conn.ChangePassword("Password");

However, the methods ChangePassword() or SetPassword() doesn't exist in System.Data.SQLite.SQLiteConnection, so it won't work. So my question is, am I missing something?

I'm using the latest release of the official SQLite Nuget Package.

1
  • 2
    Do you have a .net Core project? It's not there in .net Core, but it is there in .net Framework projects Commented Aug 15, 2019 at 10:23

1 Answer 1

4

The method is not supported in the .net Core (.net Standard) version of the library.

For connecting to a password-protected database, specify the password in the connection string. Use the SQLiteConnectionStringBuilder.Password or SQLiteConnectionStringBuilder.HexPassword properties.

For setting a password or changing the password, issue an sql pragma statement.

pragma key='NewPassword'

or

pragma rekey='NewPassword'

For details see Using the "key" PRAGMA

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

1 Comment

Thanks, that was the issue! you're a life saver!

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.