以下方法,应该检查记录是否已经存在于表中或者没有。但是,我收到语法错误没有这样的列。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检查一次。 –