Board index » delphi » Problems Opening a Stream in ADORecordSet

Problems Opening a Stream in ADORecordSet

Hi,

Does anyone know how to open a textstream in an ADO RecordSet
(disconnected)?

I'm trying the function below and the problem is I get error messages about
the parameters (wrong type, out of range or in conflict) when trying to open
the recordset.

Does anyone know what I'm doing wrong?

Any help most appreciated.

Regards,
Mike

    function XMLStrToRecordSet(XmlStr:String):ADOR_TLB._Recordset;
    var
      vTextStream     : TStringStream;
      vAdapter          : IStream;
      tmpRecordSet2 :  ADOR_TLB._RecordSet;
      vtMissing : Variant;
    begin
        TVarData (vtMissing).vType := varError;
      try
        vTextStream:=  TStringStream.Create(XMLSTR);
        vTextStream.Position:=0;
        tmpRecordSet2 := CreateComObject(ADOR_TLB.CLASS_Recordset) as
ADOR_TLB._Recordset;
      { Connect the adapter and the memory stream. }

        vAdapter := TStreamAdapter.Create(vTextStream, soReference);
        tmpRecordSet2.CursorLocation := adUseClient;

tmpRecordSet2.Open(OleVariant(vAdapter),vtmissing,ADOR_TLB.adOpenStatic,ADOR
_TLB.adLockOptimistic,-1);
        finally
        vTextStream.Free;
        end;
    result := tmpRecordSet2;
    end;

 

Re:Problems Opening a Stream in ADORecordSet


try

tmpRecordset2.Open(vAdapter, EmptyParam, adOpenUnspecified,
adLockUnspecified, adCmdFile);

vtMissing should be EmptyParam - OleVariant with VarType = varError and
VError = VAR_PARAMNOTFOUND.

adOpenUnspecified, adLockUnspecified - no difference for in-memory
recordset - you will have the same features anyway.

----------------------------------------------------------------
Regards,
Viatcheslav V. Vassiliev
http://www.oledbdirect.com
The fastest way to access MS SQL Server, MS Jet (MS Access)
and Interbase (through OLEDB) databases.

"Mike Irvine" <mike_a_irv...@hotmail.com> ???Y/???Y ?????
???Y??: news:3e68c054$1@newsgroups.borland.com...

Quote
> Hi,

> Does anyone know how to open a textstream in an ADO RecordSet
> (disconnected)?

> I'm trying the function below and the problem is I get error messages
about
> the parameters (wrong type, out of range or in conflict) when trying to
open
> the recordset.

> Does anyone know what I'm doing wrong?

> Any help most appreciated.

> Regards,
> Mike

>     function XMLStrToRecordSet(XmlStr:String):ADOR_TLB._Recordset;
>     var
>       vTextStream     : TStringStream;
>       vAdapter          : IStream;
>       tmpRecordSet2 :  ADOR_TLB._RecordSet;
>       vtMissing : Variant;
>     begin
>         TVarData (vtMissing).vType := varError;
>       try
>         vTextStream:=  TStringStream.Create(XMLSTR);
>         vTextStream.Position:=0;
>         tmpRecordSet2 := CreateComObject(ADOR_TLB.CLASS_Recordset) as
> ADOR_TLB._Recordset;
>       { Connect the adapter and the memory stream. }

>         vAdapter := TStreamAdapter.Create(vTextStream, soReference);
>         tmpRecordSet2.CursorLocation := adUseClient;

tmpRecordSet2.Open(OleVariant(vAdapter),vtmissing,ADOR_TLB.adOpenStatic,ADOR

- Show quoted text -

Quote
> _TLB.adLockOptimistic,-1);
>         finally
>         vTextStream.Free;
>         end;
>     result := tmpRecordSet2;
>     end;

Re:Problems Opening a Stream in ADORecordSet


Hi Viatcheslav,

Thanks a lot! That works great now...

I knew it was something about that vtmissing parameter I was trying to
emulate the C++ code for the missing param
(I never knew about the EmptyParam).

Thanks again,
Mike

"Viatcheslav V. Vassiliev" <supp...@oledbdirect.com> wrote in message
news:3e68e7b3@newsgroups.borland.com...

Quote
> try

> tmpRecordset2.Open(vAdapter, EmptyParam, adOpenUnspecified,
> adLockUnspecified, adCmdFile);

> vtMissing should be EmptyParam - OleVariant with VarType = varError and
> VError = VAR_PARAMNOTFOUND.

> adOpenUnspecified, adLockUnspecified - no difference for in-memory
> recordset - you will have the same features anyway.

> ----------------------------------------------------------------
> Regards,
> Viatcheslav V. Vassiliev
> http://www.oledbdirect.com
> The fastest way to access MS SQL Server, MS Jet (MS Access)
> and Interbase (through OLEDB) databases.

> "Mike Irvine" <mike_a_irv...@hotmail.com> ???Y/???Y ?????
> ???Y??: news:3e68c054$1@newsgroups.borland.com...
> > Hi,

> > Does anyone know how to open a textstream in an ADO RecordSet
> > (disconnected)?

> > I'm trying the function below and the problem is I get error messages
> about
> > the parameters (wrong type, out of range or in conflict) when trying to
> open
> > the recordset.

> > Does anyone know what I'm doing wrong?

> > Any help most appreciated.

> > Regards,
> > Mike

> >     function XMLStrToRecordSet(XmlStr:String):ADOR_TLB._Recordset;
> >     var
> >       vTextStream     : TStringStream;
> >       vAdapter          : IStream;
> >       tmpRecordSet2 :  ADOR_TLB._RecordSet;
> >       vtMissing : Variant;
> >     begin
> >         TVarData (vtMissing).vType := varError;
> >       try
> >         vTextStream:=  TStringStream.Create(XMLSTR);
> >         vTextStream.Position:=0;
> >         tmpRecordSet2 := CreateComObject(ADOR_TLB.CLASS_Recordset) as
> > ADOR_TLB._Recordset;
> >       { Connect the adapter and the memory stream. }

> >         vAdapter := TStreamAdapter.Create(vTextStream, soReference);
> >         tmpRecordSet2.CursorLocation := adUseClient;

tmpRecordSet2.Open(OleVariant(vAdapter),vtmissing,ADOR_TLB.adOpenStatic,ADOR

- Show quoted text -

Quote
> > _TLB.adLockOptimistic,-1);
> >         finally
> >         vTextStream.Free;
> >         end;
> >     result := tmpRecordSet2;
> >     end;

Other Threads