🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #4692

Re: inserting jpeg-images into Oracle DB

#4692
From: Nigel Jones
Date: Wed, 14 Nov 2001 17:13
84 lines
2880 bytes
A different way to do it:

To retrieve:

   TBlobField* bf = dynamic_cast<TBlobField
*>(Query1->FieldByName("BLOBFIELD"));
   TADOBlobStream* bl = new TADOBlobStream(bf, bmRead);
   try
   {
      bl->SaveToFile("bitmap.bmp");
   }
   __finally
   {
      delete bl;
   }

..and to insert:

   Query1->Edit();
   TBlobField* bf = dynamic_cast<TBlobField
*>(Query1->FieldByName("BLOBFIELD"));
   TADOBlobStream* bl = new TADOBlobStream(bf, bmWrite);
   try
   {
      bl->LoadFromFile("bitmap.bmp");
   }
   __finally
   {
      delete bl;
      Query1->Post();
   }

Or something like that!

HTH

--
Nigel Jones, FASL
____________________________________________________________
"The views of the author may not necessarily reflect those of the company."

"Arnie Mauer" <amauer@vrms.com> wrote in message news:3bf1308a_1@dnews...
> Note: I use the OraOLEDB.Oracle OLEDB provider, not ODBC.
>
> There might be better ways, but this is how I do it:
>
> // qry is a TADOQuery *
>
>    qry->SQL->Add( "INSERT INTO MyTable (MyBlob) VALUES (:blob)" );
>    TMemoryStream *MS = new TMemoryStream;
>    MS->Write(  MyBlobBuffer, sizeof( MyBlobBuffer )  );
>    MS->Seek( 0, soFromBeginning );
>    qry->Parameters->Items[0]->LoadFromStream( MS, ftBlob );
>    delete MS;
>    qry->ExecSQL();
>
> To get it back:
>
>     qry->SQL->Add( "SELECT MyBlob FROM MyTable WHERE ..." );
>     qry->Open();
>    TBlobStream *pBlob = (TBlobStream *)
> ry->CreateBlobStream( qry->FieldByName("MyBlob"),
>               Db::bmRead );
>    pBlob->Position = 0;
>    pBlob->Read( (void *) MyBlobBuffer, sizeof( MyBlobBuffer )  );
>    delete pBlob;
>
> Hope it helps.
>
> - Arnie
>
>
> "Martina Petrovicova" <martina@microstep-mis.com> wrote in message
> news:3bf0d69b_1@dnews...
> > Can anybody help me how to insert jpeg images into Oracle Database in
the
> > filed , which type is BLOB?
> >
> > Thanks,
> > Martina.
> >
> >
>
>
Technical Details
Message-ID: <3bf2a696_2@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newsfeed.media.kyoto-u.ac.jp!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews
References: <3bf0d69b_1@dnews> <3bf1308a_1@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10698b,b364dabd743c92f9
X-Google-Attributes: gid10698b,public
X-Google-ArrivalTime: 2001-11-14 09:29:15 PST
From: "Nigel Jones" <npj@fasl.co.uk>
Newsgroups: borland.public.cppbuilder.database.ado
References: <3bf0d69b_1@dnews> <3bf1308a_1@dnews>
Subject: Re: inserting jpeg-images into Oracle DB
Date: Wed, 14 Nov 2001 17:13:18 -0000
Lines: 86
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
NNTP-Posting-Host: 212.125.84.166
Message-ID: <3bf2a696_2@dnews>
X-Trace: dnews 1005758102 212.125.84.166 (14 Nov 2001 09:15:02 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newsfeed.media.kyoto-u.ac.jp!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews