Put an Image in a database ? 
Author Message
 Put an Image in a database ?

Hi all

I try to put an image in a database.
Is it something like that ?

          Query1.FieldByName('Image').value := Form1.Image1.Picture.Bitmap;

The compiler reports an error : not the same type....

Any ideas ?

Thanks for reading !



Wed, 18 Jun 1902 08:00:00 GMT  
 Put an Image in a database ?
if you are accessing the table via a TTable dataset then you can do
something like this

{ create a stream object...}
Form1.Image1.Picture.Bitmap.SaveToStream(stream)
TBlobField(tblimages.FieldByName('image')).LoadFromStream(stream);

Quote:

>I try to put an image in a database.
>Is it something like that ?

>          Query1.FieldByName('Image').value := Form1.Image1.Picture.Bitmap;

>The compiler reports an error : not the same type....



Wed, 18 Jun 1902 08:00:00 GMT  
 Put an Image in a database ?
On Tue, 02 Nov 1999 21:50:06 GMT, "Louis Dumortier"

Quote:

>I try to put an image in a database.
>Is it something like that ?

>          Query1.FieldByName('Image').value := Form1.Image1.Picture.Bitmap;

>The compiler reports an error : not the same type....

One way to do this is with the TBlobField.Assign method.

  (Query1.FieldByName('Image') as
    TBlobField).Assign(Form1.Image1.Picture.Bitmap);

As the FieldByName method (and Fields property) only provide a reference of
type TField, not TBlobField, you should typecast that reference as a
TBlobField. This is done in the above example.

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
Steve Koterski              "Health nuts are going to feel stupid someday,
Felton, CA                  lying in hospitals dying of nothing."
                                                              -- Redd Foxx



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Transparent Image put

2. Bgi-image put.

3. Putting image on the screen

4. Fast put image

5. How to Put Image data to Paradox BLOB fields

6. Put your Delphi Database on the Internet

7. Putting an array in an database???

8. Problem Putting Graphics In Database

9. is it possible to put in a DLL components related to database

10. Q: Put blob into Oracle database field

11. how to put picture in the delphi database?

12. Help-Database in a Remote Location: Where to put the data files

 

 
Powered by phpBB® Forum Software