I have a simple SQLite db with one table named agenda and a field that is VARCHAR(35) and is named "slots". I have a FireDAC TFDConnection and TFDquery to be able to query the table. My project is a multi-device application in C++ targeting 32-bit windows and 64-bit IOS. On my form I have a ListBox control. I'm trying to populate this ListBox1 from the query. I can't figure out how to make it work properly in IOS.
My problem line of code below has to do with trying to format the string that comes back from the query. I've tried different combinations based on: http://docwiki.embarcadero.com/Libraries/Tokyo/en/System.AnsiStrings.Format but nothing works.
Form1->ListBox1->Items->Add(System::UnicodeString::Format("%s", arguments, ARRAYSIZE(arguments) - 1));
void LoadListBox1()
{
TFDQuery *query;
query = new TFDQuery(NULL);
__try {
query->Connection = Form1->FDConnection1;
query->SQL->Text = "SELECT * FROM agenda";
query->Open();
while (!query->Eof) {
TVarRec arguments[1] = {query->FieldByName("slots")->AsString};
Form1->ListBox1->Items->Add(System::UnicodeString::Format("%s", arguments, ARRAYSIZE(arguments) - 1));
query->Next();
}
}
__finally {
query->Close();
query->DisposeOf();
}
}
Using Tokyo C++ Builder 10.2 Update 2. IOS is latest for iPhone.
Ok, I'm as dumb as a box of hammers. The SQLite field is a varchar and I should have made it a Text field. The new line of code below works fine once I modified my "slots" field to be a Text data type.
Form1->ListBox1->Items->Add(query->FieldByName("slots")->AsString);
See: http://docwiki.embarcadero.com/RADStudio/Tokyo/en/SQLite_support_in_RAD_Studio