Article View: borland.public.cppbuilder.database.ado
Article #1609Re: ADO - Access - Images
From: Viatcheslav V. Vassiliev
Date: Tue, 01 Jun 2004 11:19
Date: Tue, 01 Jun 2004 11:19
83 lines
4040 bytes
4040 bytes
> This works fine, but, it seems to be inserting the image data into a new
> row, how can I make it go in a row "WHERE ID = 1" for instance?
Change "Form1->query->Open();" to "Form1->query->Edit();". You should set
cursor to needed row. You may use "SELECT * FROM map WHERE ID=1" or traverse
dataset until getting needed row or use Locate() method. If you need just to
update table, you may use TADOCommand with parameters ("UPDATE map SET map =
:map WHERE ID=1") and use parameters.
> Is it just a matter of using SaveToStream instead?
Yes.
TFileStream * Blob = new TFileStream(Form1->Open->FileName,
fmOpenRead);
try
{
Form1->query->SQL->Text = "SELECT * FROM map WHERE ID=1";
Form1->query->Open();
((TBlobField*)Form1->query->FieldByName("map"))->SaveToStream(Blob);
Form1->query->Close();
}
__finally
{
delete Blob;
}
> Shouldn't the image be the same when taken out as when putting it in?
With BLOB (LONG BINARY) you actually save array of bytes and get back the
same array of bytes. Nothing is encoded/decoded. With MEMO field convertion
Unicode/ANSI could happen.
//------------------------------------------
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)
"Zannha" <asd> �������/�������� � �������� ���������:
news:40bbae99$1@newsgroups.borland.com...
> More blob questions :-)
>
> I found this code by Viatcheslav in another post:
>
> TFileStream * Blob = new TFileStream(Form1->Open->FileName, fmOpenRead);
> try
> {
> Form1->query->SQL->Text = "SELECT * FROM map";
> Form1->query->Open();
> Form1->query->Insert();
>
> ((TBlobField*)Form1->query->FieldByName("map"))->LoadFromStream(Blob);
> Form1->query->Post();
> Form1->query->Close();
> }
> __finally
> {
> delete Blob;
> }
>
> This works fine, but, it seems to be inserting the image data into a new
> row, how can I make it go in a row "WHERE ID = 1" for instance?
>
> Second, when taking the image back out from the database, how would I do
> that? Is it just a matter of using SaveToStream instead? An example would
be
> great.
>
> Third, i'm inserting PNG images with transparent values, and I though I
read
> somewhere that access databases convert images to bitmaps, is this still
> true when it reads LONG BINARY in the field? Shouldn't the image be the
same
> when taken out as when putting it in?
>
> In advance thanks!
>
>
Technical Details
Message-ID:
<40bc6655$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!controlnews3.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!t-online.de!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<40b92b3f$1@newsgroups.borland.com> <40b99cf2$2@newsgroups.borland.com> <40b9c366@newsgroups.borland.com> <40b9c6b4$1@newsgroups.borland.com> <40b9c91d$1@newsgroups.borland.com> <40b9fd17@newsgroups.borland.com> <40bbae99$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 10698b,6d0993f8aff78e0a X-Google-Attributes: gid10698b,public From: "Viatcheslav V. Vassiliev" <support@oledbdirect.com> Newsgroups: borland.public.cppbuilder.database.ado References: <40b92b3f$1@newsgroups.borland.com> <40b99cf2$2@newsgroups.borland.com> <40b9c366@newsgroups.borland.com> <40b9c6b4$1@newsgroups.borland.com> <40b9c91d$1@newsgroups.borland.com> <40b9fd17@newsgroups.borland.com> <40bbae99$1@newsgroups.borland.com> Subject: Re: ADO - Access - Images Date: Tue, 1 Jun 2004 15:19:53 +0400 Lines: 85 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: 213.234.218.42 Message-ID: <40bc6655$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1086088789 213.234.218.42 (1 Jun 2004 04:19:49 -0700) Path: arc1-ca.pugleaf.net!controlnews3.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!t-online.de!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail