以下方法,應該檢查記錄是否已經存在於表中或者沒有。但是,我收到語法錯誤沒有這樣的列。sqlite異常沒有這樣的列
public void ifExist(int myId)
{
string dbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "ormdemo.db3");
var db = new SQLiteConnection(dbPath);
SQLiteCommand cmd = new SQLiteCommand(db);
cmd.CommandText = "SELECT count(*) FROM storeConsumption WHERE Id = ?"+ myId;
int count = Convert.ToInt32(cmd.ExecuteScalar<storeConsumption>());
if (count == 0)
{
Console.WriteLine("The record is NOT Existed");
}
else
{
Console.WriteLine("The record is Existed");
}
}
我也試着像這樣運行:
cmd.CommandText = "SELECT count(*) FROM storeConsumption WHERE Id= ?'"+ myId+"'";
雖然,仍然有同樣的錯誤。如果你有一個想法,我該如何解決它,我會感激不盡。
}
卸載應用程序再次intall檢查一次。 –