我的代码:
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;有如下错误:
could not convert variant of type (UnicodeString) into type (Double)'. 我用的是MySql
performers里的id是 int(3)型
Author里的id是也是int(3)型

解决方案 »

  1.   

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

  2.   


      self.Author.DataSet.CommandText:= 
      'select * from performers where id = '+Self.Book.FieldByName('id').Value; 
    改为
    self.Author.DataSet.CommandText:= 
      'select * from performers where id = '+Self.Book.FieldByName('id').AsString;
      

  3.   

    self.Author.DataSet.CommandText:= 
      'select * from performers where id = '+InttoStr(Self.Book.FieldByName('id').AsInteger);
      

  4.   

    程序修改了,但现在出新错误了。提示说MYSQL语法有错误。原因是这样:
    上面程序实现的是
    select * from performers where id=1
    但MySql正确语法是:
    select * from performers where id='1'不知道该怎么改。
      

  5.   

    我上面说错了,select * from performers where id=1 在mysql下运行也通过了。修改后程序:
    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;可上面程序在delphi里老是提示:
    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.
      

  6.   

    语句再加上  .....'id').AsString + ';';