I am trying to set up a simple grid and allow a user to search for a particular surname from a db. I have a datasource, SQLand my DBgrid. If I press the button without a WHERE statement it selects and displays all the surnames. If I try and put a edit box in and make it select a certain name , it always throws an error stating too few parameters.
My code is
I have searched high and low on the internet to try and find the answer but to no avail. Have any of you guys an idea to why this doesn't work? TIA.
My code is
Code:
procedure TForm1.Button1Click(Sender: TObject);
var s : string;
begin
s := 'select * from tblMyTable where SURNAME = ' + (Edit1.Text);
Query1.Active := false;
Query1.Sql.Clear;
Query1.Sql.Text := s;
Query1.ExecSQL;
Query1.Active := true;
end;
I have searched high and low on the internet to try and find the answer but to no avail. Have any of you guys an idea to why this doesn't work? TIA.