SQLiteUnityKit icon indicating copy to clipboard operation
SQLiteUnityKit copied to clipboard

Getting Bool

Open afavar opened this issue 10 years ago • 1 comments

Hi, how can i get the boolean value in my database column?

SqliteDatabase sqlDB = new SqliteDatabase ("config.db"); string query = "SELECT bookName ,read " + "FROM Books"; var data = sqlDB.ExecuteQuery (query); bool boolData = data.Rows[0]["read"];

Currently it returns data.Rows[0]["read"] as object so it gives me an error: Cannot implicitly convert type object' tobool'. An explicit conversion exists (are you missing a cast?)

afavar avatar Sep 13 '15 15:09 afavar

Sqlite has no internal representation for boolean values, but they can be represented with integers,

bool read = ((int)result.Rows [i] ["read"]) > 0;

would suffice in this case

isaacgoodfellow avatar Dec 11 '15 19:12 isaacgoodfellow