不是,我把代码贴出来吧
是用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.