I recently started building Android apps using Xamarin. I am trying to create a small local database with SQLite. I used the following tutorial from the Xamarin documentation site .
Sorry, I get an error message:
Error CS0019: Operator '! = 'cannot be applied to operands of type "Task" and "int" (CS0019)
My code is as follows:
private string createDatabase(string path) { try { var connection = new SQLiteAsyncConnection(path);{ connection.CreateTableAsync<Person>(); return "Database created"; } } catch (SQLiteException ex) { return ex.Message; } } private string insertUpdateData(Person data, string path) { try { var db = new SQLiteAsyncConnection(path); if ( db.InsertAsync(data) != 0) db.UpdateAsync(data); return "Single data file inserted or updated"; } catch (SQLiteException ex) { return ex.Message; } } private int findNumberRecords(string path) { try { var db = new SQLiteConnection(path);
And the Person class is as follows:
using System; using SQLite; namespace HelloWorld { public class Person { [PrimaryKey, AutoIncrement] public int ID { get; set; } public string FullName { get; set; } public string CarLicense { get; set; } public override string ToString() { return string.Format("[Person: ID={0}, FullName={1}, CarLicense={2}]", ID, FullName, CarLicense); } } }
Can someone help me with this error?
android c # sqlite xamarin xamarin.android
The user without number
source share