🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.database.ado
5 messages
5 total messages Started by Russell Allen Fri, 16 Sep 2005 11:00
ADODB.Stream objects and Variants
#587
Author: Russell Allen
Date: Fri, 16 Sep 2005 11:00
17 lines
1507 bytes
Hi all,

I'm working on CBuilder 5 without ADO controls, so I'm currently using Variants to access ADO.  How can I get the following code (or something like it) to work?

void putStream (TMemoryStream *memStream) {
  Variant stream = CreateOleObject("ADODB.Stream");
  stream.OleProcedure("Open");
  stream.OleProcedure("Write", memStream);
}

I know the above code doesn't appear to do anything, but I've got code I've left out which then goes on to do something with the stream Variant.

Thanks all,

Russ
Russell Allen
Re: ADODB.Stream objects and Variants
#588
Author: Viatcheslav V. Vassiliev
Date: Fri, 16 Sep 2005 20:40
37 lines
2294 bytes
You can:
- wrap stream using TOleStream (ADODB.Stream implements IStream);
- wrap your memStream with TStreamAdapter and use it instead of ADODB.Stream 
(when you pass stream, pass Variant of type IUnknown and value should have 
interface that can be queried for IStream, IStream is implemented in 
TStreamAdapter).

//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi for Win32 + 
ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)

"Russell Allen" <russell.allen@bt.com> �������/�������� � �������� 
���������: news:432aa5ea$1@newsgroups.borland.com...
>
> Hi all,
>
> I'm working on CBuilder 5 without ADO controls, so I'm currently using 
> Variants to access ADO.  How can I get the following code (or something 
> like it) to work?
>
> void putStream (TMemoryStream *memStream) {
>  Variant stream = CreateOleObject("ADODB.Stream");
>  stream.OleProcedure("Open");
>  stream.OleProcedure("Write", memStream);
> }
>
> I know the above code doesn't appear to do anything, but I've got code 
> I've left out which then goes on to do something with the stream Variant.
>
> Thanks all,
>
> Russ
> Russell Allen 
Re: ADODB.Stream objects and Variants
#589
Author: Mark Guerrieri
Date: Fri, 16 Sep 2005 22:37
48 lines
1909 bytes
Import the ADO type library and include the resulting import file, i.e.

#include "AdoDb_TLB.H"

Then you can do this:

void putStream (TMemoryStream *memStream)
{
  StreamPtr pStream = CoStream::Create();
  OLECHECK(pStream->Open( {appropriate open parameters} ));

  memStream->Seek(0, soFromBeginning);
  bool FReleaseStream = true;
  TStreamAdapter *sa = new TStreamAdapter(memStream, soReference);
  if(!sa)
    throw Exception("Could not create Stream interface");
  try
  {
    IUnknown* iunk = NULL;
    try
    {
      OLECHECK(sa->QueryInterface(IID_IUnknown, (LPVOID*)&iunk));
      if(iunk == NULL)
        throw Exception("Stream interface does not implement the IUnknown
interface");

      TVariant v = iunk;

      OLECHECK2(pStream->Write(v));
    }
    __finally
    {
      if(iunk)
      {
        FReleaseStream = false;
        iunk->Release();
      }
    }
  }
  __finally
  {
    if(FReleaseStream && sa)
      delete sa;
  }
}


Mark
Re: ADODB.Stream objects and Variants
#590
Author: Viatcheslav V. Vassiliev
Date: Sat, 17 Sep 2005 10:02
67 lines
2598 bytes
You can use

TVariant v = iunk;

instead of pStream and pass it to ADO. This will remove a need to have 
second stream.

//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi for Win32 + 
ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)

"Mark Guerrieri" <mguerrieri@nospam_cmsgrp.com> �������/�������� � �������� 
���������: news:432b48dd$1@newsgroups.borland.com...
> Import the ADO type library and include the resulting import file, i.e.
>
> #include "AdoDb_TLB.H"
>
> Then you can do this:
>
> void putStream (TMemoryStream *memStream)
> {
>  StreamPtr pStream = CoStream::Create();
>  OLECHECK(pStream->Open( {appropriate open parameters} ));
>
>  memStream->Seek(0, soFromBeginning);
>  bool FReleaseStream = true;
>  TStreamAdapter *sa = new TStreamAdapter(memStream, soReference);
>  if(!sa)
>    throw Exception("Could not create Stream interface");
>  try
>  {
>    IUnknown* iunk = NULL;
>    try
>    {
>      OLECHECK(sa->QueryInterface(IID_IUnknown, (LPVOID*)&iunk));
>      if(iunk == NULL)
>        throw Exception("Stream interface does not implement the IUnknown
> interface");
>
>      TVariant v = iunk;
>
>      OLECHECK2(pStream->Write(v));
>    }
>    __finally
>    {
>      if(iunk)
>      {
>        FReleaseStream = false;
>        iunk->Release();
>      }
>    }
>  }
>  __finally
>  {
>    if(FReleaseStream && sa)
>      delete sa;
>  }
> }
>
>
> Mark
>
> 
Re: ADODB.Stream objects and Variants
#594
Author: Russell Allen
Date: Fri, 23 Sep 2005 11:11
77 lines
3048 bytes
Thanks guys,

This looks like exactly what I was after!  Very much appreciated.  :)

Russ

"Viatcheslav V. Vassiliev" <support@oledbdirect.com> wrote:
>You can use
>
>TVariant v = iunk;
>
>instead of pStream and pass it to ADO. This will remove a need to have 
>second stream.
>
>//------------------------------------------
>Regards,
>Vassiliev V. V.
>http://www.managed-vcl.com - using .Net objects in Delphi for Win32 + 
>ADO.Net
>http://www.oledbdirect.com - The fastest way to access MS SQL Server,
>MS Jet (Access) and Interbase (through OLEDB)
>
>"Mark Guerrieri" <mguerrieri@nospam_cmsgrp.com> �������/�������� � �������� 
>���������: news:432b48dd$1@newsgroups.borland.com...
>> Import the ADO type library and include the resulting import file, i.e.
>>
>> #include "AdoDb_TLB.H"
>>
>> Then you can do this:
>>
>> void putStream (TMemoryStream *memStream)
>> {
>>  StreamPtr pStream = CoStream::Create();
>>  OLECHECK(pStream->Open( {appropriate open parameters} ));
>>
>>  memStream->Seek(0, soFromBeginning);
>>  bool FReleaseStream = true;
>>  TStreamAdapter *sa = new TStreamAdapter(memStream, soReference);
>>  if(!sa)
>>    throw Exception("Could not create Stream interface");
>>  try
>>  {
>>    IUnknown* iunk = NULL;
>>    try
>>    {
>>      OLECHECK(sa->QueryInterface(IID_IUnknown, (LPVOID*)&iunk));
>>      if(iunk == NULL)
>>        throw Exception("Stream interface does not implement the IUnknown
>> interface");
>>
>>      TVariant v = iunk;
>>
>>      OLECHECK2(pStream->Write(v));
>>    }
>>    __finally
>>    {
>>      if(iunk)
>>      {
>>        FReleaseStream = false;
>>        iunk->Release();
>>      }
>>    }
>>  }
>>  __finally
>>  {
>>    if(FReleaseStream && sa)
>>      delete sa;
>>  }
>> }
>>
>>
>> Mark
>>
>> 
>
>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads