大家帮我看看这段代码错在那里
- Delphi(Pascal) code
procedure TForm6.ComboBox1Change(Sender: TObject);beginADOQuery2.Close;ADOQuery2.SQL.Clear;ADOQuery2.SQL.Add('select * from 混合料 where 批号 like '+combobox1.text+'');ADOQuery2.Open;edit1.text:= ADOQuery1.fieldbyname('co').AsString ;end;end.想实现的功能就是,通过改变combobox1中下拉条中的值,使edit1中的值也跟着变化。
程序运行时提示的错误是YGR60(即combobox1.textr的值)没有默认参数,请各位哥哥帮我分析一下,
[解决办法]
试试这句:ADOQuery2.SQL.Add('select * from 混合料 where 批号 like '+''''+'%'+combobox1.text+'%'+'''');
[解决办法]
('select * from 混合料 where 批号 like '+combobox1.text+'');这句错误。
('select * from 混合料 where 批号 like '+''''+'%'+combobox1.text+'%'+'''');
试一下。
[解决办法]
procedure TForm6.ComboBox1Change(Sender: TObject);
begin
ADOQuery2.Close;
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('select * from 混合料 where 批号 like '+QuotedStr('%'+ combobox1.text+'%');
ADOQuery2.Open;
edit1.text:= ADOQuery1.fieldbyname('co').AsString ;
end;
end.
[解决办法]
//少了个括号
procedure TForm6.ComboBox1Change(Sender: TObject);
begin
ADOQuery2.Close;
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('select * from 混合料 where 批号 like '+QuotedStr('%'+ combobox1.text+'%'));
ADOQuery2.Open;
edit1.text:= ADOQuery1.fieldbyname('co').AsString ;
end;
end.
[解决办法]
引号用错了。