看看我的代码
procedure TForm1.BitBtn1Click(Sender: TObject);
var STableName,ssdbfile: string;
begin
STableName:=mydm.dataform.Table1.TableName;
ssdbfile:=stablename;
STableName:=copy(STableName,pos('_',StableName)+1,
pos('.',StableName)-pos('_',StableName)-1);
ssdbfile:=copy(ssdbfile,1,pos('.',ssdbfile)-1);
with mydm.dataform.Query1do
begin
SQL.Clear;
SQL.Add('insert into '+trim(edit1.text));
SQL.Add('select name,address,post from');
SQL.Add(STableName+' where name in (');
SQL.Add('select name from '+ssdbfile);
SQL.Add('where wget = 1)');
try
Prepare;
ExecSQL;
Except
showmessage(Sql.text);
end;
end;
end;