第一个MTS数据模块(协调对象)代码:
procedure TdmoCF_customer_info.Get_Customers(const vSql_Str: WideString;
var vDatas: OleVariant);
begin
try
ADOQry_F_customer_info.Close;
ADOQry_F_customer_info.SQL.Clear;
ADOQry_F_customer_info.SQL.Text := vSql_Str;
ADOQry_F_customer_inf
pen;
SetComplete ;
except
SetAbort;
end;
// try/except
end;
第二个MTS数据模块(逻辑对象)代码:
procedure TdmoQF_customer_info.Get_Customers(const vSql_Str: WideString;
var vDatas: OleVariant);
var
execObj:IdmoCF_customer_info;
begin
try
try
execObj:= CodmoCF_customer_info.CreateRemote('ly2001038');
execObj.Get_Customers(vSql_Str,vDatas) ;
ClientDataSet_F_customer_info.Active := True;
(下面这一句也试过了)
//ClientDataSet_F_customer_info.CommandText :='select * from f_customer_info where customer_id='+''''+'00002583'+'''';
ClientDataSet_F_customer_inf
pen;
vDatas := ClientDataSet_F_customer_info.Data;
SetComplete ;
except
SetAbort ;
end;
finally // wrap up
ClientDataSet_F_customer_info.Active := False;
end;
// try/finally
end;
第三个MTS对象(逻辑对象,客户端就调用他的方法)代码:
(FMyDM : TdmoQF_customer_info;)
procedure TmtsQF_customer_info.GetOrg_Customers( const vOrgID: WideString;
var vData: OleVariant);
var Sql_str : String;
begin
try
Sql_str := 'select a.*, b.* from f_customer_info a, code_trade b '
+ ' where b.trade_id = substring(a.trade_id,1,8)+''' + '0000' ;
{if ( vOrgID <> '') then
begin
Sql_str := Sql_str +' and customer_id in (select customer_id from ' + vOrgID +')';
end ;
}
if ( vOrgID <> '') then
begin
Sql_str := Sql_str +' and customer_id in ('+''''+'00002583'+ ''''+')';
end ;
Sql_str := Sql_str +' order by a.bookin_id ';
FMyDM.Get_Customers(Sql_str,vData);
SetComplete ;
except
SetAbort ;
end;
end;
客户端代码:
procedure TForm1.GetCustomers(const vFilter: WideString;
var vData: OleVariant);
var
qObj : ImtsQF_customer_info;
begin
qObj:= ComtsQF_customer_info.CreateRemote('ly2001038');
qObj.GetOrg_Customers(vFilter,vData ) ;
showmessage(vData);
end;