Using:
OS-X 10.6.8
Lazarus 1.2.4, FPC 2.6.4
MySQL 5.6.19 (32-bit)
qSundry is TSQLQuery; textSundry is TDBText; lShareCount and lConnCount are TLabels. The SQL statements being assigned to qSundry.SQL work when I use them in the SQL Editor in the Object Inspector, returning the expected values. The SQL statements are copied from the SQL editor and pasted into the unit code, with the single quotes escaped - the statement shows correctly in the ShowMessage. But it crashes with "You have an error in your SQL syntax".
Can anyone help?
procedure TfMain.FormClick(Sender: TObject);
begin
qSundry.Active:=false;
qSundry.SQL.Clear;
qSundry.SQL.Add('''select count(ShareNo) from Shares'';');
showMessage(qSundry.SQL.Text);
qSundry.Active:=true;
lShareCount.Caption := lShareCount.Caption + textSundry.Caption;
qSundry.Active:=false;
qSundry.SQL.Clear;
qSundry.SQL.Add('''select count(ConnectionNo) from Connections'';');
qSundry.Active:=true;
lConnCount.Caption := lConnCount.Caption + textSundry.Caption;
end;