I’m developing a game with Unreal Engine 5.2.1 and C++.
I’m using a wrapper from Unreal to access a SQLite 3 database, but I’m having a problem when I try to bind parameters to the statement.
This is the declarations:
const FString LocationASCIINameKey = "$locationAsciiName";
const FString LocationNameKey = "$locationName";
const FString CoordinatesSQL =
"SELECT Latitude, Longitude "
"FROM Coordinates "
"WHERE Name = '" + LocationNameKey + "' OR ASCIIName = '" + LocationASCIINameKey + "'";
And this is the code that connect to the database:
FSQLiteDatabase* CatalogueDb = new FSQLiteDatabase();
if (CatalogueDb->Open(*DbFileFullPath, ESQLiteDatabaseOpenMode::ReadOnly))
{
FSQLitePreparedStatement* PreparedStatement = new FSQLitePreparedStatement();
if (PreparedStatement->Create(*CatalogueDb, *CoordinatesSQL, ESQLitePreparedStatementFlags::Persistent))
{
TArray<FString> Keys;
Keys.Add(LocationNameKey);
Keys.Add(LocationASCIINameKey);
TArray<FString> Values;
Values.Add(Location);
Values.Add(Location);
if (BindStatement(PreparedStatement, Keys, Values))
{
The method is:
bool ULocationGameInstanceSubsystem::BindStatement(
FSQLitePreparedStatement* Statement,
const TArray<FString> Keys,
const TArray<FString> Values) const
{
for (int i = 0; i < Keys.Num(); i++)
{
if (!Statement->SetBindingValueByName(*Keys[i], *Values[i]))
{
return false;
}
}
return true;
}
But Statement->SetBindingValueByName(*Keys[i], *Values[i])
always returns false, and I don’t what to check because there isn’t any code returned.
I have tried to check the FSQLitePreparedStatement
header file, but there isn’t anything to get an error message or a status code.
What am I doing wrong?