Im running a couple of queries (well attempting to) using Lazarus objects rather than programatically, I have my DB Connections and Transactions setup and interacting with my Queries and am reading and initial query into a TDBGrid. Now what I want to do is be able to click on a grid cell and select an ID value to use in a query.
I have a TSQLQuery object setup and linked to a source, I entered this into the SQL property:
SELECT * FROM tbl_accounts
WHERE tbl_accounts.ClientID = :AccID
However I can't work out how to pass my parameter into the object... My procedure looks like this:
procedure TtcheckHome.accResultsCellClick(Column: TColumn);
begin
selected := listAccounts.Fields[0].AsString;
// accSelect.SQL.Text := 'SELECT * FROM tbl_accounts WHERE tbl_accounts.ClientID = 2';
accSelect.Params.ParamByName('AccID').AsString := selected;
textEdit.Text := accSelect.FieldByName('AccountNumber').AsString;
end;
This always returns with accSelect : Field name AccountNumber not found, if I remove any references to Params however and hardcode an ID into the query it works perfectly. This leads me to believe that my method for using bound parameters is wrong! What have I missed?