Board index » delphi » ADO - COM [Return Recordset to ASP from com Object]

ADO - COM [Return Recordset to ASP from com Object]

?Can I return recordset from MTS COM abject to asp page?
I wrote this function in com object to return  the Recordset, but calling
this object from asp page show error 'Catastrophic failure /App/SegApp.asp,
line 11'.

I use Delphi 5, IIS5, W2kServer, MTS.

function TCMose.ReturnRecordset : OleVariant;
begin
Result := False;
try
  AppCon := TADOConnection.Create(nil);
  AppCon.CommandTimeout := 30;
  AppCon.ConnectionString := 'Provider=SQLOLEDB.1;Password=password;Persist
Security Info=false;User ID=username;Initial Catalog=mose;Data
Source=ALPHAServer;Use Procedure for Prepare=1;Auto Translate=True;Packet
Size=4096;Workstation ID=JRIVERA';
  Appcon.CursorLocation := clUseClient;
  AppCon.DefaultDatabase := 'MOSE';
  AppCon.Mode := cmRead;
  AppCon.LoginPrompt := false;
  AppCon.Open('username','password');
  AppRs := TADOQuery.Create(nil);
  AppRs.Connection := AppCon;
  AppRs.SQL.Add('Select * from mose_tema');
  AppRs.CursorLocation := clUseClient;
  AppRs.LockType := ltReadOnly;
  AppRs.CursorType := ctOpenForwardOnly;
  AppRs.Open;
  Result := AppRs.Recordset;
finally
  AppRs.Close;
  AppCon.Close;
  AppRs.Free;
  AppCon.Free;
 end;
end;

Some help will be gratefully.

 

Re:ADO - COM [Return Recordset to ASP from com Object]


I would use ADO COM directly. Your problem is because ADO recordset is bound
to TADOQuery, so you can't really return it to the caller. Something like
this should be OK:

func TFoo.GetData: OleVariant;
var
  rs: Recordset;
begin
  rs := CoRecordset.Create;
  rs.CursorLocation := adUseClient;
  rs.Open (...);
  rs.Set_ActiveConnection (UnAssigned);
  Result := rs;
end;

--
have fun
Binh Ly
http://www.techvanguards.com

Quote
"Julio Rivera" <jcriver...@hotmail.com> wrote in message

news:3b72ab7c_2@dnews...
Quote

> ?Can I return recordset from MTS COM abject to asp page?
> I wrote this function in com object to return  the Recordset, but calling
> this object from asp page show error 'Catastrophic failure
/App/SegApp.asp,
> line 11'.

> I use Delphi 5, IIS5, W2kServer, MTS.

> function TCMose.ReturnRecordset : OleVariant;
> begin
> Result := False;
> try
>   AppCon := TADOConnection.Create(nil);
>   AppCon.CommandTimeout := 30;
>   AppCon.ConnectionString :=

'Provider=SQLOLEDB.1;Password=password;Persist

- Show quoted text -

Quote
> Security Info=false;User ID=username;Initial Catalog=mose;Data
> Source=ALPHAServer;Use Procedure for Prepare=1;Auto Translate=True;Packet
> Size=4096;Workstation ID=JRIVERA';
>   Appcon.CursorLocation := clUseClient;
>   AppCon.DefaultDatabase := 'MOSE';
>   AppCon.Mode := cmRead;
>   AppCon.LoginPrompt := false;
>   AppCon.Open('username','password');
>   AppRs := TADOQuery.Create(nil);
>   AppRs.Connection := AppCon;
>   AppRs.SQL.Add('Select * from mose_tema');
>   AppRs.CursorLocation := clUseClient;
>   AppRs.LockType := ltReadOnly;
>   AppRs.CursorType := ctOpenForwardOnly;
>   AppRs.Open;
>   Result := AppRs.Recordset;

Other Threads