李维书里的例子:
目的是从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;
目的是从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;
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型的原因?该怎么办
也是这个错误,[DCC Error]: 'End’ expected but string constant found
begin
self.Author.Active:=false;
self.Author.DataSet.CommandText:= 'select * from performers where id = '+Self.Book.FieldByName('id').AsString ;
self.Author.active:=true;
end;
照抄
'select * from performers where id =' + IntToStr(Self.Book.FieldByName('id').Value);这次是提示说我的Mysql语法不对,该怎么弄
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'.
'select * from performers where id = '+ ''''+Self.Book.FieldByName('id').Value+'''' ;可运行的话有如下错误:
could not convert variant of type (UnicodeString) into type (Double)'.郁闷坏了
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; 这样试试