Andrew Simpson
Andrew Simpson

Reputation: 7314

I am trying to open a connection to my SQLite Database in WPF

I am using SQLite.Net-PCL (trying to) in my WPF application.

I am stuck trying to make a connection.

I have this:

var connector = new SQLiteConnection(S, "My_DB_Path");

where 'S' is of type:

SQLite.Net.Interop.ISQLitePlatform 

But how do I make this setting - confused...

Upvotes: 1

Views: 1209

Answers (3)

Luiz
Luiz

Reputation: 208

In Android, I'm using new SQLiteConnection(new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid(), path);

For WPF maybe you can use a generec platform. See this topic

Upvotes: 0

Nishanth Bhat
Nishanth Bhat

Reputation: 56

You can use the SQLiteConnection as follows

string dbPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "db_Name.db");

        db = new SQLiteConnection(dbPath);

        if (db != null)
            db.CreateTable<Table_Name>();

Upvotes: 0

Drew Noakes
Drew Noakes

Reputation: 310792

Googling around, it seems that the SQLiteConnection class has a constructor that just accepts a string. Can you use that one instead?

Something like:

new SQLiteConnection("Data Source=MyDatabase.sqlite;Version=3;")

Upvotes: 1

Related Questions