Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting Bool #9

Open
afavar opened this issue Sep 13, 2015 · 1 comment
Open

Getting Bool #9

afavar opened this issue Sep 13, 2015 · 1 comment

Comments

@afavar
Copy link

afavar commented Sep 13, 2015

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?)

@isaacgoodfellow
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants