W
woodyou
Unregistered / Unconfirmed
GUEST, unregistred user!
以下是我的例子procedure TFrmdictionary.tsdoctorShow(Sender: TObject);var a:Integer;beginwith LISDataMod.qrytemp dobeginClose;SQL.Clear; SQL.Add('if exists(select name from sysobjects where name='+'''+#tmptable+'''+ 'and type='+'''+U+'''+') drop table tmptable') ; execsql; end; with LISDataMod.qrytemp dobegin Close;SQL.Clear;SQL.Add('create table #tmptable(Infectedpatch_myid char(4), Infectedpatch char(20), brevitycode char(20))') ; execsql;end; with LISDataMod.qrycomm do begin Close; SQL.Clear; SQL.Add('select * from Infectedpatchs order by Infectedpatch_id'); Open; if RecordCount>0 then begin First; for a:=0 to RecordCount-1 do begin LISDataMod.qrytemp.Close; LISDataMod.qrytemp.SQL.Clear; LISDataMod.qrytemp.sql.Add('insert into #tmptable (Infectedpatch_myid,Infectedpatch,brevitycode) ' + 'valuesmy0,:my1,:my2)'); LISDataMod.qrytemp.parameters.items[0].value:=Encrypt(Trim(fieldbyname('Infectedpatch_myid').AsString),funs.key); LISDataMod.qrytemp.parameters.items[1].value:=Encrypt(Trim(fieldbyname('Infectedpatch').AsString),funs.key); LISDataMod.qrytemp.parameters.items[2].value:=Encrypt(Trim(fieldbyname('brevitycode').AsString),funs.key); LISDataMod.qrytemp.prepared:=true; LISDataMod.qrytemp.execsql; Next; end; end; end; with LISDataMod.qrytemp dobeginClose;SQL.Clear; SQL.Add(' select * from #tmptable order by Infectedpatch_myid ') ; Open;end;dsInfect.Enabled:=False;dsInfect.DataSet:= LISDataMod.qrytemp;dsInfect.Enabled:=true; end;为何老是提示临时表“对象“#tmptable ”无效”,好象是临时表#tmptable没有创立,请问如何解决临时表#tmptable创立及使用问题?