如何传参数到TRODataSnapModule中(RemObject方法) ( 积分: 5 )

  • 主题发起人 主题发起人 aKnightChen
  • 开始时间 开始时间
A

aKnightChen

Unregistered / Unconfirmed
GUEST, unregistred user!
以前,我是采用SocketConnect+RemoteDataModule+Midas方法
现在,我想采用RemObject方法,
中间层TRODataSnapModule中,元件有:ADOConnection+DataSetProvider+AdoQuery
我现在,希望不同用户登录时,可以给不同的CommandTimeOut,
则我必须实现将一个参数(如用户ID)传到TRODataSnapModule,才可以更改CommandTimeOut
我不知道怎么实现传参数传进去?
------
(以前,我是用SocketConnect,我知道,只要在中间层模块中Type Library中定义一个过程,即可实现传参数到RemoteDataModul中。)

[实在没分了,只有5分,真不好意思]
 
以下是我在kTop上的提问链接:
http://delphi.ktop.com.tw/board.php?cid=30&fid=68&tid=91350

一位大侠回复我:
ROServer 在create Datamodule時 是使用 TROClassFactory
TROClassFactory.Create('IAppServer', Create_DataSnapModule, TAppServer_Invoker);
參考一下他的uRoserver.pas 的原碼 在建立DataSnapModule給予你要的參數

然後再寫 method 讓前端可以用SOAP或bin傳入到server端 給予DataSnapModule啟動的參數


但我看不懂。。。[:(]
 
我贴出源码,望大家有空帮看一下(本人刚开始搞RemObject)


Unit1:
---------------------------
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, uROClient, uROServer, uROIndyTCPServer, uROIndyHTTPServer,
uROBinMessage;
type
TForm1 = class(TForm)
msg_BIN: TROBinMessage;
HTTPServer: TROIndyHTTPServer;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
end.

=========================================
Unit2,(RemoteDataModul)

-------------
unit Unit2;
interface
uses {vcl:} SysUtils, Classes, DB, DBClient,
{RemObjects:} uRODataSnapModule, Provider, ADODB, uROClient,
uROSessions,uROClassFactories,uROClientIntf;
type
TRODataSnapModule2 = class(TRODataSnapModule)
con_SqlServer: TADOConnection;
qry_customers: TADOQuery;
prv_customers: TDataSetProvider;
private
{ Private declarations }
v:boolean;
public
{ Public declarations }
end;
var
RODataSnapModule2: TRODataSnapModule2;
implementation
uses {RemObjects:} uROServer, uRODataSnap_Invk;
{$R *.DFM}
procedure Create_DataSnapModule(out oInstance:IUnknown);
begin
oInstance := TRODataSnapModule2.Create(nil);
end;
initialization
TROClassFactory.Create('IAppServer', Create_DataSnapModule, TAppServer_Invoker);
end.



**********客户端**************

unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, DBClient, uROClient, uROBinMessage,
uROWinInetHttpChannel, uRODataSnapConnection, Grids, DBGrids;
type
TForm1 = class(TForm)
RODataSnapConnection: TRODataSnapConnection;
HTTPChannel: TROWinInetHTTPChannel;
ROBinMessage: TROBinMessage;
aa: TClientDataSet;
Button1: TButton;
Memo1: TMemo;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
Button2: TButton;
ClientDataSet1: TClientDataSet;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
aa.Close;
aa.CommandText:=Memo1.Lines.Text;
aa.Open;
showmessage('OPEN');
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
aa.Close;
aa.CommandText:=Memo1.Lines.Text;
aa.Execute;
showmessage('EXEC');
end;
end.
 
期待有哪位大哥帮忙一下!
 
你看一下例子,自带的SUM(A+B)怎么传数据,你怎么传就行了
 
已有思路了,
贴出来和大家分享,

搜索关键字: 楠楠群资料(多层开发绝密文档)
这里面有个例子,就是我要的.
还正在研究....[:)]
 
后退
顶部