Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   save image from database with TblobField (https://www.delphipraxis.net/176354-save-image-database-tblobfield.html)

question 29. Aug 2013 15:57

save image from database with TblobField
 
hi, i have the following query to save image from database, if i save an image which is 300 kb but when i want to save the same image from the database, it always save with a fixed size 33 kb

Code:
Query.SQL.Clear;
   Query.SQL.Add('select Image from TablePic where id =1');
   Query.Open;
BlobField := Query.FieldByName('Image ') As TBlobField;
   BlobField.SaveToFile(FileName);
dont have any idea why its save with fixed 33 kb, do you have any suggestion?

Der schöne Günther 29. Aug 2013 16:03

AW: save image from database with TblobField
 
Just a random guess: Does
Delphi-Quellcode:
TBlobField.SaveToStream(..)
yield the same result?

Also, what are you saving the image with? Can you successfully retrieve the full amount of 300KB with another application?

sx2008 29. Aug 2013 16:14

AW: save image from database with TblobField
 
Delphi-Quellcode:
Query.SQL.Text := 'select Image from TablePic where id =1';
Query.Open;
if Query.IsEmpty then // you should test this
  raise Exception.Create('image not found in database');
BlobField := Query.FieldByName('Image ') As TBlobField;
//...................................^ why is there a blank?
BlobField.SaveToFile(FileName);
Are you sure that you're checking the right file?
You should also check if the name "Image" is treated as a reserved word by your DBMS.
Probably it isn't a reserved word but if it is you will get weird results.

question 29. Aug 2013 16:24

AW: save image from database with TblobField
 
I have checked the query whether is empty or not but the query is not empty
i have also change the name Image to Bild
but still it saves the size of 33 kb

Neutral General 29. Aug 2013 16:43

AW: save image from database with TblobField
 
There's a space in your FieldByName. Maybe this causes Problems?
By the way: If you're german (because of your "Bild") then you may just speak german, because this is a german forum :mrgreen:

Uwe Raabe 29. Aug 2013 16:47

AW: save image from database with TblobField
 
Which database and which data access components?

question 29. Aug 2013 20:48

AW: save image from database with TblobField
 
it is Tquery component with mysql database and delphi 2010


Alle Zeitangaben in WEZ +1. Es ist jetzt 03:00 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz