score:2

Accepted answer

Looks like you trying to use Linq2Sql with Sqlite which isn't supported by default (only SQL Server and SQL Server CE are supported), see this question for more details.

Have a look at using Entity Framework, which supports Sqlite, instead.

score:0

I just went through this and tried to implement. Got same error, then found that we can create database using SQLiteConnection as so:

sqlcnn.CreateFile("MyDatabase.sqlite");

And then using "db" you can do all database operation. Try it.

score:0

I have found this to work for me.

            string fileDB = "Data Source=:memory:";
            Console.WriteLine(fileDB);
            SQLiteConnection conn = new SQLiteConnection(fileDB);
            DataContext db = new DataContext(conn);
            Console.WriteLine(db.Connection.ServerVersion);

Using a file, credits to this guy for the file path.

string fileDB = "Data Source=" + Directory.GetParent(Environment.CurrentDirectory).Parent.Parent.FullName +
                            @"\test.sqlite";

First check the company example of Linq2SQL here.


Related Articles