我能用这样的代码么?
procedure TForm5.Button1Click(Sender: TObject);
begin
 
adotable1.close;
if radiobutton1.checked then
adotable1.sql.clear;
adotable1.sql.add('select*from 表2 where bianhao=:bianhao');
adotable1.parameters.parambyname('bianhao').value:=trim(edit1.text);
if edit1.text=''then
begin
  application.messagebox('请输入商品编号','提示信息',64);
  edit1.setfocus;
  exit;
end;
adotable1.open;
end;
但运行的时候,错误指在adotable1.sql.clear;
希望大侠们帮帮忙。。小弟是初学者

解决方案 »

  1.   

    adotable1.sql.add('select*from 表2 where bianhao=:bianhao');->
    adotable1.sql.add('select * from 表2 where bianhao=:bianhao');
    select*from 连在一块了
    如果错误仍在:改在Adoquery控件试试
      

  2.   

    他没有把错误代码提示贴上来,怎么猜?可能是中文空格,可能是其他的,他的好像少了BEGIN END
      

  3.   

    adotable1.sql.add('select*from 表2 where bianhao=:bianhao');->
    adotable1.sql.Text :='select * from 表2 where bianhao=:bianhao';
      

  4.   

    错误:
    1.adotable是没有SQL属性的,只能设置Tablename直接关联表,要用SQL就改成adoquery吧
    2.select*from 注意空格select * from
    3.adotable1.close;最好放在if radiobutton1.checked then里面
    4.if radiobutton1.checked then要加上begin...end 
    5.if edit1.text='' then判断放在if radiobutton1.checked then这个判断外面最终代码:
    procedure TForm5.Button1Click(Sender: TObject);
    begin
      if edit1.text=''then
      begin
        application.messagebox('请输入商品编号','提示信息',64);
        edit1.setfocus;
        exit;
      end 
      else if radiobutton1.checked then
      begin
        with adoquery1 do
        begin
          close;
          sql.clear;
          sql.add('select * from 表2 where bianhao=:bianhao');
          parameters.parambyname('bianhao').value:=trim(edit1.text);
          open;
        end;
      end;
    end;
      

  5.   

    TADOTable 是没有SQL属性的。如果要用这个属性可用TADOQuery.