Article View: borland.public.cppbuilder.database.ado
Article #589Re: ADODB.Stream objects and Variants
From: Mark Guerrieri
Date: Fri, 16 Sep 2005 22:37
Date: Fri, 16 Sep 2005 22:37
48 lines
1909 bytes
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
Technical Details
Message-ID:
<432b48dd$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<432aa5ea$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,2a0e8802e733b24c X-Google-Attributes: gid10698b,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Mark Guerrieri" <mguerrieri@nospam_cmsgrp.com> Newsgroups: borland.public.cppbuilder.database.ado References: <432aa5ea$1@newsgroups.borland.com> Subject: Re: ADODB.Stream objects and Variants Date: Fri, 16 Sep 2005 18:37:39 -0400 Lines: 50 Organization: Creative Marketing Strategies X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 209.50.174.82 Message-ID: <432b48dd$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1126910173 209.50.174.82 (16 Sep 2005 15:36:13 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail