李维书里的例子:
目的是从book表中获取int型 id,然后传给author表的int型 id。该怎么做?
procedure TDataModule3.GetAuthor;
begin
  self.Author.Active:=false;
  self.Author.DataSet.CommandText:=
  'select * from performers where id = Self.Book.FieldByName('id').Value';  self.Author.active:=true;
end;

解决方案 »

  1.   

     'select * from performers where id = '+Self.Book.FieldByName('id').AsString;
      

  2.   

    'select * from performers where id = ' + IntToStr(Self.Book.FieldByName('id').Value)画蛇添足
      

  3.   

    改了,可还是有错误;
    procedure TDataModule3.GetAuthor;
    begin
      self.Author.Active:=false;
      self.Author.DataSet.CommandText:=
      'select * from performers where id = '+Self.Book.FieldByName('id').AsString'';
      self.Author.active:=true;
    end;[DCC Error]: 'End’ expected but string constant found 是不是因为我的performers表中的id是int型的原因?该怎么办
      

  4.   


    也是这个错误,[DCC Error]: 'End’ expected but string constant found 
      

  5.   

    procedure TDataModule3.GetAuthor; 
    begin 
      self.Author.Active:=false; 
      self.Author.DataSet.CommandText:= 'select * from performers where id = '+Self.Book.FieldByName('id').AsString ; 
      self.Author.active:=true; 
    end; 
    照抄
      

  6.   

    哦,有点明白了,呵呵
     'select * from performers where id =' + IntToStr(Self.Book.FieldByName('id').Value);这次是提示说我的Mysql语法不对,该怎么弄
      

  7.   

    这里回答速度真快啊,谢谢大侠们。
    you have an error in your SQL syntax; check the manual that 
    corresponds to your mysql server version for the right syntax
    to use near 'where id =1' at line 1'.
      

  8.   

    这是李维书里用的方法:
    'select * from performers where id = '+ ''''+Self.Book.FieldByName('id').Value+'''' ;可运行的话有如下错误:
    could not convert variant of type (UnicodeString) into type (Double)'.郁闷坏了
      

  9.   

    procedure TDataModule3.GetAuthor; 
    begin 
      self.Author.Active:=false; 
      self.Author.DataSet.CommandText:= 'select * from performers where id =:id ';
      self.Author.DataSet.parameters.paramByname('id').value :=Self.Book.FieldByName('id').AsString ; 
      self.Author.active:=true; 
    end; 这样试试