急救!为什么我的midas服务器有时取不到数据,连接都正常的,有代码(0分)

  • 主题发起人 主题发起人 jacket84
  • 开始时间 开始时间
J

jacket84

Unregistered / Unconfirmed
GUEST, unregistred user!
服务器一切正常,每个过程都可以执行,为什么客户端取不到数据?即使把MIDAS重新注册了还是不行?但很奇怪的是把服务器运行起来就可以取到数据了。按道理服务器端只要第一次运行注册一下不就行了吗?
 
你用的是DCOM的吧
 
不是,我把代码贴出来吧
是用socketconn
unit MainControl_RDM;

interface
uses
Windows, Messages, SysUtils, Classes, ComServ, ComObj, VCLCom, DataBkr,
DBClient, ControlSer_TLB, StdVcl, ADODB, Provider, DB;
type
TMainControlRDM = class(TRemoteDataModule, IMainControlRDM)
adcnectMain: TADOConnection;
adprocQuery: TADOStoredProc;
dspQuery: TDataSetProvider;
adprocQueryper: TADOStoredProc;
adprocQuery_Go: TADOStoredProc;
adprocQueryBill: TADOStoredProc;
adprocDelData: TADOStoredProc;
adoqUpload: TADOQuery;
dspUpload: TDataSetProvider;
adprocDelUpData: TADOStoredProc;
procedure RemoteDataModuleCreate(Sender: TObject);
procedure RemoteDataModuleDestroy(Sender: TObject);
procedure adoqUploadPostError(DataSet: TDataSet;
E: EDatabaseError;
var Action: TDataAction);
private
{ Private declarations }
protected
class procedure UpdateRegistry(Register: Boolean;
const ClassID, ProgID: string);
override;
procedure UpLoad(const UpLoadSQL: WideString;
out ErrorFlag: OleVariant);
safecall;
procedure DelData(const SiteNo, Date: WideString);
safecall;
procedure Query(const V_SiteNo: WideString;
out Data: OleVariant;
const CurDate: WideString);
safecall;
procedure Query_bill(const V_SiteNo: WideString;
out Data: OleVariant;
const CurDate: WideString);
safecall;
procedure Query_Go(const V_SiteNo: WideString;
out Data: OleVariant;
const CurDate: WideString);
safecall;
procedure Query_per(const V_SiteNo: WideString;
out Data: OleVariant;
const CurDate: WideString);
safecall;
public
{ Public declarations }
end;

implementation
uses MainControlFrm;
{$R *.DFM}
class procedure TMainControlRDM.UpdateRegistry(Register: Boolean;
const ClassID, ProgID: string);
begin
if Register then
begin
inherited UpdateRegistry(Register, ClassID, ProgID);
EnableSocketTransport(ClassID);
EnableWebTransport(ClassID);
end else
begin
DisableSocketTransport(ClassID);
DisableWebTransport(ClassID);
inherited UpdateRegistry(Register, ClassID, ProgID);
end;
end;

procedure TMainControlRDM.UpLoad(const UpLoadSQL: WideString;
out ErrorFlag: OleVariant);
begin
adoqUpload.Close;
adoqUpload.SQL.Clear;
adoqUpload.SQL.Add(UpLoadSQL);
try
adoqUpload.ExecSQL;
ErrorFlag := 0 ;
PostMessage(MainFrmHand,WM_SaveLog,0,integer(DateTimeToStr(now)+ 'UpLoad Success!'))
except
on e : Exceptiondo
begin
ErrorFlag := 1 ;
PostMessage(MainFrmHand,WM_SaveLog,0,integer(e.Message + DateTimeToStr(now)));
end;
end;
end;

procedure TMainControlRDM.RemoteDataModuleCreate(Sender: TObject);
begin
if Not( adcnectMain.Connected ) then
begin
adcnectMain.ConnectionString := MainControlForm.sConnect;
adcnectMain.Connected := true;
PostMessage(MainFrmHand,WM_SaveLog,0,integer(DateTimeToStr(Now)+ 'Connected Success'));
end;
MainControlForm.SetClientCount(1);
end;
.........................
procedure TMainControlRDM.DelData(const SiteNo, Date: WideString);
begin
with adprocDelDatado
begin
Close;
ProcedureName := 'sp_DelUpData';
Parameters.CreateParameter('@Site_No',ftString,pdInput,2,SiteNo);
Parameters.CreateParameter('@CurDate',ftString,pdInput,10,Date);
try
ExecProc;
//PostMessage(MainFrmHand,WM_SaveLog,0,integer(DateTimeToStr(Now)+'DelData: sp_DelUpData'));
close;
except
on e : Exceptiondo
PostMessage(MainFrmHand,WM_SaveLog,0,integer(e.Message + DateTimeToStr(now)));
end;
end;
end;

procedure TMainControlRDM.RemoteDataModuleDestroy(Sender: TObject);
begin
MainControlForm.SetClientCount(-1);
PostMessage(MainFrmHand,WM_SaveLog,0,integer(DateTimeToStr(Now)+'DisConnect Success'));
end;

procedure TMainControlRDM.adoqUploadPostError(DataSet: TDataSet;
E: EDatabaseError;
var Action: TDataAction);
begin
PostMessage(MainFrmHand,WM_SaveLog,0,integer(e.Message + DateTimeToStr(now)));
end;

initialization
TComponentFactory.Create(ComServer, TMainControlRDM,
Class_MainControlRDM, ciMultiInstance, tmFree);
// tmFree 线程模型Threading Model中的自由线程
// 只有tmFree才可以访问服务器界面线程
end.
 
我现在试的时候有一台机器上可以,其他机器有时候会得到数据,但很多时候没有,但服务器运行起来就都可以了,搞不明白
 
没有人懂吗?
 
接受答案了.
 

Similar threads

后退
顶部