L
luaijun
Unregistered / Unconfirmed
GUEST, unregistred user!
一.在mts对象调用另一个mts对象不成功
procedure TmtsSecurityObj.GetBooks(vCookie: OleVariant;
var vDatas: OleVariant);
var bookObj:ImtsBookObj;
aps:IAppServer;
Options:TGetRecordOptions;
iRecOut:Integer;
OwnerData:OleVariant;
Params:OleVariant;
begin
if VerifyCookie(vCookie)then
begin
try
OleCheck(ObjectContext.CreateInstance(CLASS_mtsBookObj,IID_ImtsBookObj,bookObj));
aps:=bookObj as IAppServer;
Options:=[grMetaData,grReset];
vDatas:=aps.AS_GetRecords('DataSetProvider',-1,iRecOut,Byte(Options),'',Params,OwnerData);
SetComplete;
except
SetAbort;
end;
end;
end;
以下为调用源码
LoginObj:ImtsSecurityObj;
procedure TForm1.Button3Click(Sender: TObject);
var vDatas:OleVariant;
begin
LoginObj:=ComtsSecurityObj.CreateRemote('Chinatec-laj');
LoginObj.GetBooks(Edit3.Text,vDatas);
ClientDataSet1.Data:=vDatas;
end;
调试时在OleCheck中停下来不继续执行,按F7会执行SetAbort;
客户端出错信息为"invlid data Packet"
按李维的说法,在mts中调用mts 组件效率比直接在客户端中调要高,但是这样为什么不行呢?调试他给的
源码也不行
二.另一个例子,ClientDataSet的PacketRecords不起作用,无论高为多少,都把mts DataModule
中取得的数据一次全取过来,这个程序本意是分次取所需的数据
procedure TForm1.ClientDataSet1BeforeGetRecords(Sender: TObject;
var OwnerData: OleVariant);
begin
if not first then
begin
try
vOwnerData := GetKeyFieldValue(Sender);
OwnerData := vOwnerData;
except
on exceptiondo
end;
end;
end;
function TForm1.GetKeyFieldValue(Sender: TObject): OleVariant;
var
aCDS : TClientDataSet;
begin
try
try
aCDS := TClientDataSet.Create(Self);
aCDS.Data := ClientDataSet1.Data;
aCDS.Last;
Result := aCDS.FieldByName('emp_id').Value;
finally // wrap up
aCDS.Free;
end;
// try/finally
except
on e: Exceptiondo
raise;
end;
end;
procedure TForm1.btnMoreClick(Sender: TObject);
var
CurRecord : TBookMark;
begin
first:=false;
try
if (not bTrueEOF) then
begin
try
CurRecord := ClientDataSet1.GetBookmark;
if (ClientDataSet1.GetNextPacket < ClientDataSet1.PacketRecords) then
bTrueEOF := True;
finally
ClientDataSet1.FreeBookmark(CurRecord);
end;
end;
except
on Exceptiondo
;
end;
DBGrid1.Refresh;
edtRecordCount.Text := IntTostr(ClientDataSet1.RecordCount);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
first:=true;
DCOMConnection1.Connected := True;
ClientDataSet1.Open;
Button2.Enabled:=false;
end;
调试时,if (ClientDataSet1.GetNextPacket < ClientDataSet1.PacketRecords) then
中ClientDataSet1.GetNextPacket的值是inaccessible
mts 要求之一就是大量数据分次取,这个例子怎么通不过
本人初涉mts三层编程,请各们大侠指正
procedure TmtsSecurityObj.GetBooks(vCookie: OleVariant;
var vDatas: OleVariant);
var bookObj:ImtsBookObj;
aps:IAppServer;
Options:TGetRecordOptions;
iRecOut:Integer;
OwnerData:OleVariant;
Params:OleVariant;
begin
if VerifyCookie(vCookie)then
begin
try
OleCheck(ObjectContext.CreateInstance(CLASS_mtsBookObj,IID_ImtsBookObj,bookObj));
aps:=bookObj as IAppServer;
Options:=[grMetaData,grReset];
vDatas:=aps.AS_GetRecords('DataSetProvider',-1,iRecOut,Byte(Options),'',Params,OwnerData);
SetComplete;
except
SetAbort;
end;
end;
end;
以下为调用源码
LoginObj:ImtsSecurityObj;
procedure TForm1.Button3Click(Sender: TObject);
var vDatas:OleVariant;
begin
LoginObj:=ComtsSecurityObj.CreateRemote('Chinatec-laj');
LoginObj.GetBooks(Edit3.Text,vDatas);
ClientDataSet1.Data:=vDatas;
end;
调试时在OleCheck中停下来不继续执行,按F7会执行SetAbort;
客户端出错信息为"invlid data Packet"
按李维的说法,在mts中调用mts 组件效率比直接在客户端中调要高,但是这样为什么不行呢?调试他给的
源码也不行
二.另一个例子,ClientDataSet的PacketRecords不起作用,无论高为多少,都把mts DataModule
中取得的数据一次全取过来,这个程序本意是分次取所需的数据
procedure TForm1.ClientDataSet1BeforeGetRecords(Sender: TObject;
var OwnerData: OleVariant);
begin
if not first then
begin
try
vOwnerData := GetKeyFieldValue(Sender);
OwnerData := vOwnerData;
except
on exceptiondo
end;
end;
end;
function TForm1.GetKeyFieldValue(Sender: TObject): OleVariant;
var
aCDS : TClientDataSet;
begin
try
try
aCDS := TClientDataSet.Create(Self);
aCDS.Data := ClientDataSet1.Data;
aCDS.Last;
Result := aCDS.FieldByName('emp_id').Value;
finally // wrap up
aCDS.Free;
end;
// try/finally
except
on e: Exceptiondo
raise;
end;
end;
procedure TForm1.btnMoreClick(Sender: TObject);
var
CurRecord : TBookMark;
begin
first:=false;
try
if (not bTrueEOF) then
begin
try
CurRecord := ClientDataSet1.GetBookmark;
if (ClientDataSet1.GetNextPacket < ClientDataSet1.PacketRecords) then
bTrueEOF := True;
finally
ClientDataSet1.FreeBookmark(CurRecord);
end;
end;
except
on Exceptiondo
;
end;
DBGrid1.Refresh;
edtRecordCount.Text := IntTostr(ClientDataSet1.RecordCount);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
first:=true;
DCOMConnection1.Connected := True;
ClientDataSet1.Open;
Button2.Enabled:=false;
end;
调试时,if (ClientDataSet1.GetNextPacket < ClientDataSet1.PacketRecords) then
中ClientDataSet1.GetNextPacket的值是inaccessible
mts 要求之一就是大量数据分次取,这个例子怎么通不过
本人初涉mts三层编程,请各们大侠指正