Catastrophic failure with COM+ client Options

来源:互联网 发布:js怎么隐藏span 编辑:程序博客网 时间:2024/05/16 05:28

这时我在新闻组上发布的帖子

大意是返回的记录集不能为空

 

I ran into 'Catastrophic failure' with my COM+ client app when passing the
query sql string to the procedure on COM+ server app, on the server app,
there is a datamodule containing ADOQuery component to fetch recordset from
the SQL Server Express 2005, both the server and client applications are on
the same computer.

Here are my code snippets:

//server side
{
    dm : instance of  class(TDataModule)
    cn: TADOConnection;
    qry: TADOQuery;
    dspQuery: TDataSetProvider;

 

}

function TCOMTest.GetRemoteRecordset(const strQuery: WideString;
  var RetVal: OleVariant): OleVariant;
begin
  with dm do
    begin
      try
        qry.Close;
        qry.SQL.Clear;
        qry.SQL.Add(strQuery);
        qry.Open;
        RetVal := dspQuery.Data;
        SetComplete;
      except
        SetAbort;
      end;
    end;
  Result := 1;
end;

//client side
//clCOM:TClientDataSet;

var
  d:OleVariant ;
  svr:ICOMTest ;
begin
       svr :=CoCOMTest.CreateRemote('127.0.0.1');
       strQuery := 'Select top ' + IntToStr(len) +
        ' * from Lcustomers where customerid like ''' + bgn + '%'';';

        svr.GetRemoteRecordset(strQuery ,d);
        clCOM.Data :=d;

        ......
end;

What's wrong with my codes?

I made a slight modification on the codes on server side, the dm would be
created dynamically when executing TCOMTest.GetRemoteRecordset, the
Catastrophic failure disappeared, but another exception 'Invalid Data
Packet' was threwn out. How to handle it?

来自专家的答复:

 

Most likely an Exception on the server so that Retval isn't assigned with the
Data from you datasetprovider. You have to check that your Datapacket is valid
before assigning it to clientdataset.Data. Assigning an empty OLEVariant will
throw the mentioned exception.

--
Ralf Jansen

 

 
原创粉丝点击