1
我想檢查一個名爲isSolved的表項的布爾型字段。然後編寫一個依賴於布爾值運行代碼的if條件。檢查SQLite表項字段 - C#WPF
我已經試過這種方法:
foreach (int level in builtInLevels2)
{
myImage = new Image();
int levelNowInt = level;
string levelName = "Level " + level;
SQLiteConnection sqlConnection;
SQLiteCommand sqlite_cmd;
try
{
// create a new database connection:
sqlConnection = new SQLiteConnection(dbConnectionString);
// open the connection:
sqlConnection.Open();
// create a new SQL command:
sqlite_cmd = sqlConnection.CreateCommand();
sqlite_cmd.CommandText = "select isSolved from Level where name = " + "'" + levelName + "'" + ";";
var dbEntry = sqlite_cmd.ExecuteNonQuery();
MessageBox.Show(dbEntry.ToString());
}
VAR dbEntry始終是0。然而,這不是一個布爾值,爲表項的布爾值在某些情況下,實際上1。我如何正確地做到這一點?
謝謝,它的工作原理。 – user2602079