Lawson Lutchman wrote:
Hi Forum,
I hope this post makes sense as I am trying to create a search
feature against an ADO DB that accepts an input from a combobox. I
have an ADO connection, an ADOQuery and a DBGrid. I have looked at
configuring parameters in the ADOQuery but cannot get the function to
link to the parameter. I have a combobox called cbsRoleFilter, I
would like to display the ADOQuery results (filtered) in the grid.
My current code is.
procedure TfrmViewUsers.btnRoleSearchClick(Sender: TObject);
begin
with ADOQuery2 do begin
Close;
SQL.Clear;
dbgrid2.DataSource:= SQL.Add('select UserName,Role from FOYB_Login
where Role='+ QuotedStr (cbxRoleFilter.Text));
dbgrid2.Visible:=True;
Open;
end;
end;
end.
I get..
[Error] ViewUsers.pas(79): Incompatible types: 'TDataSource' and
'Integer'
This may be the entirely incorrect approach to the problem...any
suggestion will help..
Regards,
You do not mention a TDataSource component (eg DataSource1) that should
be connected to the dbgrid2.DataSource property. The ADOQuery2 should
be connected to the DataSource1.Dataset property.
Also for clarity I recommend you do not use 'with' statements.
DataSource1.Dataset := ADOQuery2;
dbgrid2.DataSource := DataSource1;
ADOQuery2.Close;
ADOQuery2.SQL.Text := 'select UserName,Role from FOYB_Login where
Role=' + QuotedStr (cbxRoleFilter.Text));
dbgrid2.Visible := True;
ADOQuery2.Open;
HTH.
Steve
Connect with Us