55

I have tried SQLiteConnection(":memory:") and SQLiteConnection("sqlite::memory:") but both of these fail with 'Invalid ConnectionString format'

3 Answers 3

95

try

var connection = new SQLiteConnection("Data Source=:memory:");
3
  • 3
    This doesn't work for me. I get an exception 'The path is not of a legal form.'
    – Steztric
    Commented Jan 27, 2017 at 11:52
  • @Steztric try not putting a space between Data Source => new SqliteConnection("DataSource=:memory:")
    – AZ_
    Commented Feb 4, 2020 at 8:24
  • var connection = new SqliteConnection("Filename=:memory:"); Commented Nov 10, 2022 at 13:07
7

I'm using this:

var connectionStringBuilder = new SQLiteConnectionStringBuilder { DataSource = ":memory:" };
var connection = new SQLiteConnection(connectionStringBuilder.ToString());
4

Maybe it's too late, but FullUri=file::memory:?cache=shared; is working.

It's knowledge from forum question

2
  • 2
    Any more info? I get System.ArgumentException : Keyword not supported: 'fulluri'. using var connection = new SqliteConnection("FullUri=file::memory:?cache=shared;");
    – Andez
    Commented Sep 23, 2018 at 21:37
  • @Andrez Lowercase SqliteConneciton you are using is from different package Microsoft.Data.Sqlite which doesn't work with FullUri parameter.
    – ghord
    Commented Nov 11, 2022 at 13:36

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.