Solved

How to save picture to file without Tblobfield

Posted on 2004-08-06
1
480 Views
Last Modified: 2010-04-05
now i'm using TBlobField(AdoQuery2.fieldbyname('picture')).SaveToFile('Temp.jpg');
it works with dbgrid
but i need to save jpg picture without db grid..

This not work:

AdoQuery2.SQL.Clear; AdoQuery2.SQL.Add('Select picture from klientai where id = '+ id +'');
AdoQuery2.Open;
if not Adoquery2.IsEmpty then  //is there a picture?
    begin
      AdoQuery2.SaveToFile('Temp.jpg');
      Image1.Picture.LoadFromFile('Temp.jpg');
    end
  else
    begin
      Image1.Picture.Bitmap.Assign(Nil);  //there is no Image
    end;
0
Comment
Question by:selas
1 Comment
 
LVL 17

Accepted Solution

by:
geobul earned 500 total points
ID: 11736355
Hi,

AdoQuery2.SQL.Clear; AdoQuery2.SQL.Add('Select picture from klientai where id = '+ id +'');
AdoQuery2.Open;
if not Adoquery2.IsEmpty then  //is there a picture?
    begin
      TBlobField(AdoQuery2.fieldbyname('picture')).SaveToFile('Temp.jpg'); // <-- changed !!! You don't need dbgrid for doing this
      Image1.Picture.LoadFromFile('Temp.jpg');
    end
  else
    begin
      Image1.Picture.Bitmap.Assign(Nil);  //there is no Image
    end;

BTW 'id' field should be of integer type and 'id' variable should be String if you want to get any record from the database.

Regards, Geo
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question