Search code examples
sqlitexamarin.formssqlite.net

Xamarin Forms SQLite issue with SQLiteAsyncConnection


I'm following the following Xamarin example from the official documentation on using SQLite database functionality in a Xamarin.forms app.

https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/databases/

The problem is, when copying from the sample project, the sqlite.net version it uses is old and so the following function errors:

    public class TodoItemDatabase
{
    readonly SQLiteAsyncConnection database;

    public TodoItemDatabase(string dbPath)
    {
        database = new SQLiteAsyncConnection(dbPath);
        database.CreateTableAsync<TodoItem>().Wait();
    }

SQLiteAsyncConnection is not recognised.

Now i could add the async pcl sqlite library instead, but the tutorial gets other errors with connection string of type String being passeed to:

 database = new SQLiteAsyncConnection(dbPath);

Any info or help on how the best way to move forward with the tutorial? Or is there an upto date best practice on this?

Thanks


Solution

  • My Fault. Installed the wrong nuget package.

    I Made sure it was the SQLite-netpcl official one.

    Works fine now.