7

I have a Sqlite database that I include with my MonoTouch app. It has worked fine for me so far, but now I want to open it in read-only mode rather than read-write.

So I have changed the connection string to include 'Read Only=True', but when I call Open(), I get the following error:

Library used incorrectly (at Mono.Data.Sqlite3.Open)

If I dig into the exception it shows

_errorCode = Misuse

and that's about all the info it gives.

Here's the code:

var _conn = new SqliteConnection("Data Source=db/sampleDb;Read Only=True");
_conn.Open ();

4 Answers 4

10

You found a bug in Mono.Data.Sqlite.dll.

The Create flag is appended (by default) before the ReadOnly flag is parsed and set. The resulting flag is invalid and sqlite reports an error.

I will fix this for future releases (of Mono and MonoTouch...). If this blocks you then please open a bug report on http://bugzilla.xamarin.com and I'll attach a fixed assembly (with instructions to replace the existing one) to the bug report.

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

2 Comments

Very useful to know, thanks a lot. I'm not exactly blocked by it but I would like to open a bug to track the status - will do so now.
In case this is of use to people, here is a link to the bug I raised: bugzilla.xamarin.com/show_bug.cgi?id=2721
2

This worked for me (aspnet core):

var _conn = new SqliteConnection("Data Source=db/sampleDb;mode=ReadOnly");

Comments

1

Have you tried?:

var _conn = new SqliteConnection("Data Source=db/sampleDb;mode=ro");

Comments

0

Your code is correct, I just tried it (not using MonoTouch) and it worked for me.

Do you have the latest version of System.Data.SQLite.dll? If yes, then maybe it's a problem related to MonoTouch.

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.