S
summer_core99
Unregistered / Unconfirmed
GUEST, unregistred user!
function TOKDM.GetData(AConnection: TADOConnection; ASQL: string; var AData: Variant): Boolean;var qry: TADOQuery; dsp: TDataSetProvider; cds: TClientDataSet;begin qry := TADOQuery.Create(nil); dsp := TDataSetProvider.Create(nil); cds := TClientDataSet.Create(nil); try try //ClientDataSet建立Midas的连接关系 qry.Connection := AConnection; dsp.DataSet := qry; dsp.Options := [poAllowCommandText]; cds.SetProvider(dsp); with qry do begin Close; SQL.Clear; SQL.Text := ASQL; Open; cds.Open; AData := cds.XMLData; //AData := SoapPacket(AData); //Soap封包,采用先用Zlib压缩再进行Base64编码 Close; end; Result := True; except Result := False; end; finally //cds.Free; //不能释放cds,否则会出现access violation at address错误 dsp.Free; qry.Free; end; end;第一次调用可以通过,第二次调用就出错,位置在qry := TADOQuery.Create(nil);这一句出错。就是最后不能把cds释放了,一释放就出现access violation at address错误,已经在DLL的开始入加入了COM的初始化了,还是不行。