RemoteDataModule引用自定义class,在RemoteDataModule中创建class实例时报错(100分)

  • 主题发起人 主题发起人 qinzusong
  • 开始时间 开始时间
Q

qinzusong

Unregistered / Unconfirmed
GUEST, unregistred user!
在 &nbsp;RemoteDataModule引用如下<br>&nbsp; &nbsp; public<br>&nbsp; &nbsp; CommObj1:tSrvComObject;<br>&nbsp;RemoteDataModule创建实例如下<br>&nbsp; CommObj1.create();<br><br>报错为Access violation at address 0040424f in module '中间层程序名'<br>我在一般的vcl appliction中引用这个类没有报这个错误。<br><br>class 定义如下<br>unit sOIObjectPool;<br><br>interface<br><br>Uses SysUtils , Classes, ExtCtrls, Controls , Comobj, AdoDB, Provider,<br>&nbsp; Dialogs, &nbsp;db, DataBkr, sIObjectPool;<br><br>type TSrvComObject = Class<br>&nbsp; &nbsp; Query: tadoquery;<br>&nbsp; &nbsp; Dsp: TDataSetProvider;<br>&nbsp; &nbsp; bIsUsing:Boolean;<br>&nbsp; &nbsp; Time:ttimer;<br>&nbsp; &nbsp; iRunTime:Integer;<br>&nbsp; private<br><br>&nbsp; public<br>&nbsp; &nbsp; constructor create();<br>&nbsp; &nbsp; destructor destroy();override;<br>&nbsp; &nbsp; procedure InitInstance(rdm:TRemoteDataModule);safecall;<br>&nbsp; &nbsp; procedure FinishRequest();safecall;<br>&nbsp; &nbsp; procedure BeginUeing(); safecall;<br><br>&nbsp; &nbsp; procedure TimeOnTimer(Sender:tObject);<br>&nbsp; &nbsp; procedure QueryAfterClose(DataSet: TDataSet);<br>&nbsp; &nbsp; procedure QueryAfterOpen(DataSet: TDataSet);<br><br>&nbsp; end;<br><br>implementation<br><br>uses sDm, sCommMethod;<br><br>procedure TSrvComObject.BeginUeing();<br>begin<br><br>&nbsp; bIsUsing:=True;<br>&nbsp; Time.Enabled:=True;<br>&nbsp; iRunTime:=0;<br>end;<br><br>constructor TSrvComObject.create();<br>begin<br>&nbsp; inherited create;<br>end;<br><br>procedure TSrvComObject.InitInstance(rdm:TRemoteDataModule);<br>begin<br>&nbsp; if query=nil then<br>&nbsp; &nbsp; Query:= tadoquery.Create(rdm);<br>&nbsp; Query.Connection:=fDm.ADOConn;<br>&nbsp; Query.Name:=GetNewCName();<br>&nbsp; if Dsp=nil then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; Dsp:= TDataSetProvider.Create(rdm);<br>&nbsp; &nbsp; &nbsp; Dsp.Name:=GetNewCName;<br>&nbsp; &nbsp; &nbsp; Dsp.DataSet:=Query;<br>&nbsp; &nbsp; &nbsp; rdm.RegisterProvider(Dsp);<br>&nbsp; &nbsp; end;<br>&nbsp; bIsUsing:=False;<br>&nbsp; Time:=ttimer.Create(nil);<br>&nbsp; Time.Enabled:=False;<br>&nbsp; Time.Interval:=1000;<br>&nbsp; iRunTime:=0;<br>&nbsp; Time.OnTimer:=TimeOnTimer;<br>&nbsp; query.AfterOpen:=QueryAfterOpen;<br>&nbsp; query.AfterClose:=QueryAfterClose;<br>end;<br><br>destructor TSrvComObject.destroy;<br>begin<br>&nbsp; inherited;<br>&nbsp; Query:=nil;<br>&nbsp; Dsp:=nil;<br>&nbsp; Time:=nil; &nbsp;<br>&nbsp; Query.Free;<br>&nbsp; Dsp.Free;<br>&nbsp; Time.Free;<br>end;<br><br>procedure TSrvComObject.FinishRequest;<br>begin<br>&nbsp; Query.Close;<br>&nbsp; Time.Enabled:=False;<br>&nbsp; iRunTime:=0;<br>&nbsp; bIsUsing:=False;<br>end;<br><br>procedure TSrvComObject.QueryAfterClose(DataSet: TDataSet);<br>begin<br>&nbsp; FinishRequest;<br>end;<br><br>procedure TSrvComObject.QueryAfterOpen(DataSet: TDataSet);<br>begin<br>&nbsp; BeginUeing();<br>end;<br><br>procedure TSrvComObject.TimeOnTimer(Sender: tObject);<br>begin<br>&nbsp; inc(iRunTime);<br>&nbsp; if iRunTime=1800 then<br>&nbsp; &nbsp; FinishRequest();<br>end;<br><br>end.
 
后退
顶部