Procedure TForm1.Com boBoxEx1Change (Sender: TObject);
The begin
If (comboboxex1. Text<> ") then
The begin
With Query1 do
The begin
close;
SQL. The Clear;
SQL. The Add (' Select distinct name FROM student where names like: p ');
Params. ParamByName (" p "). The Value:='%' + trim (comboboxex1. Text) + '%';
The open;
end;
While not query1. Eof do
The begin
ComboBoxex1. Items. The add (query1. Fieldbyname (' name '). AsString) are identical.
Query1. Next;
end;
end;
end;
CodePudding user response:
And the likeCodePudding user response:
Empty the COMBOBOX, in front of the query to addprocedure TForm1.Com boBoxEx1Change (Sender: TObject);
The begin
If (comboboxex1. Text<> ") then
The begin
With Query1 do
The begin
close;
SQL. The Clear;
SQL. The Add (' Select distinct name FROM student where names like: p ');
Params. ParamByName (" p "). The Value:='%' + trim (comboboxex1. Text) + '%';
The open;
end;
While not query1. Eof do
The begin
Combobox1. Items. The Clear;
ComboBoxex1. Items. The add (query1. Fieldbyname (' name '). AsString) are identical.
Query1. Next;
end;
end;
end;
CodePudding user response:
Thank you for the original poster zhangzhen_927116 points, but still I tried I can'tCodePudding user response: