我的代码:
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)型
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)型
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;
'select * from performers where id = '+InttoStr(Self.Book.FieldByName('id').AsInteger);
上面程序实现的是
select * from performers where id=1
但MySql正确语法是:
select * from performers where id='1'不知道该怎么改。
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.