format firedac query result as string for listbox

  

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));

Here is my relevant code:

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.

Comments are closed.