Board index » delphi » putting bitmaps INTO a dbase blob field?

putting bitmaps INTO a dbase blob field?

Many third party books, many FAQs, demo programs, etc. deal with how to
display graphics that are already captured and stored in a dbase or
paradox blob field. What about the other direction? I am trying to put
about 150 bitmaps into that many records in a dbf or db file, and I can
find little in the way of example code, at least that I can make run.
Are there some examples around of code to copy a bitmap to a clipboard?
An old FAQ shows how to paste it from the clipboard to a dbimage, like
putting the data ON a clipboard is too trivial to show. Or are there
better ways to stash graphic blob info directly into memo fields?
Currently, I am getting a lot of diagnostics that say my bitmap is
invalid when I attempt to put it in a dbf memo field, or paste to a
tdbimage component, and yet it loads and displays in a timage just fine,
using the loadfromfile method. Grrr. Please! Help! my email:
w...@rpinet.com. Thanks.
 

Re:putting bitmaps INTO a dbase blob field?


Quote
On Mon, 13 Sep 1999 09:51:03 -0700, Bill Burns <w...@rpinet.com> wrote:
>Many third party books, many FAQs, demo programs, etc. deal with how to
>display graphics that are already captured and stored in a dbase or
>paradox blob field. What about the other direction? I am trying to put
>about 150 bitmaps into that many records in a dbf or db file, and I can
>find little in the way of example code, at least that I can make run.

[...]

If you are using a TTable or TQuery component with an editable dataset, try
the TBlobField.LOadFromFile method.

  (Table1.Fields[19] as TBlobField).LoadFromFile('c:\spot.bmp');

If you are using an INSERT statement executed from a TQuery, represent the
BLOB field using a parameter in the SQL statement. Use the
TParam.LoadFromFile method to copy from bitmap file to parameter. Use the
Params property or ParamByName method of the TQuery to get this TParam
reference.

  with Query1 do begin
    with SQL do begin
      Clear;
      Add('INSERT INTO "YourTable.dbf"');
      Add('(FileNameField, TheBlobField)');
      Add('VALUES (:FileNameParam, :BloFieldParam)');
    end;
    Params[0].AsString := FileNameVar;
    Params[1].LoadFromFile('c:\spot.bmp');
    ExecSQL;
  end;

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

Re:putting bitmaps INTO a dbase blob field?


I must be missing something very basic. when I tried this line with my TTable
(actually wwTTable), the program raised exception class C0000005 with message
'access violation at 0x4be41c1b: write of address 0xdd4000'. Do I have to be
using the dBase driver for dBase 7 for this to work? I have been using the
driver for dbase 4 (shooting for compatibility with Delphi 1).

  (Table1.Fields[19] as TBlobField).LoadFromFile('c:\spot.bmp');

Thanks for any help.

Bill B.

Quote
Steve Koterski wrote:
> On Mon, 13 Sep 1999 09:51:03 -0700, Bill Burns <w...@rpinet.com> wrote:

> >Many third party books, many FAQs, demo programs, etc. deal with how to
> >display graphics that are already captured and stored in a dbase or
> >paradox blob field. What about the other direction? I am trying to put
> >about 150 bitmaps into that many records in a dbf or db file, and I can
> >find little in the way of example code, at least that I can make run.

> [...]

> If you are using a TTable or TQuery component with an editable dataset, try
> the TBlobField.LOadFromFile method.

>   (Table1.Fields[19] as TBlobField).LoadFromFile('c:\spot.bmp');

> If you are using an INSERT statement executed from a TQuery, represent the
> BLOB field using a parameter in the SQL statement. Use the
> TParam.LoadFromFile method to copy from bitmap file to parameter. Use the
> Params property or ParamByName method of the TQuery to get this TParam
> reference.

>   with Query1 do begin
>     with SQL do begin
>       Clear;
>       Add('INSERT INTO "YourTable.dbf"');
>       Add('(FileNameField, TheBlobField)');
>       Add('VALUES (:FileNameParam, :BloFieldParam)');
>     end;
>     Params[0].AsString := FileNameVar;
>     Params[1].LoadFromFile('c:\spot.bmp');
>     ExecSQL;
>   end;

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

Re:putting bitmaps INTO a dbase blob field?


Quote
On Mon, 13 Sep 1999 16:08:39 -0700, Bill Burns <w...@rpinet.com> wrote:
>I must be missing something very basic. when I tried this line with my TTable
>(actually wwTTable), the program raised exception class C0000005 with message
>'access violation at 0x4be41c1b: write of address 0xdd4000'. Do I have to be
>using the dBase driver for dBase 7 for this to work? I have been using the
>driver for dbase 4 (shooting for compatibility with Delphi 1).

>  (Table1.Fields[19] as TBlobField).LoadFromFile('c:\spot.bmp');

The above syntax is valid -- at least in 32-bit Delphi. I do not have
16-bit Delphi installed to test it. But the table level might be the source
of the problem. You see, the dBASE IV table specification included a memo
column, but no binary (or BLOB column). So you can store large amounts of
text in a dBASE IV table, but it does not look like you can store binary
data in that table.

I cannot remember whether that last version of the 16-bit BDE (version
2.52) supported dBASE 5 for Windows tables (level 5 dBASE tables). The
specification for that table level *does* include a binary column type. If
you can, use that table type. Otherwise, you may have to switch to another
table type, like Paradox for example.

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

Re:putting bitmaps INTO a dbase blob field?


Hi ! i have the same problem like you, i mean the problem with storing an
image in blob field in paradox data base. If you have already the solution
can you write me about it?
Quote
Bill Burns wrote in message <37DD2B77.7B45D...@rpinet.com>...
>Many third party books, many FAQs, demo programs, etc. deal with how to
>display graphics that are already captured and stored in a dbase or
>paradox blob field. What about the other direction? I am trying to put
>about 150 bitmaps into that many records in a dbf or db file, and I can
>find little in the way of example code, at least that I can make run.
>Are there some examples around of code to copy a bitmap to a clipboard?
>An old FAQ shows how to paste it from the clipboard to a dbimage, like
>putting the data ON a clipboard is too trivial to show. Or are there
>better ways to stash graphic blob info directly into memo fields?
>Currently, I am getting a lot of diagnostics that say my bitmap is
>invalid when I attempt to put it in a dbf memo field, or paste to a
>tdbimage component, and yet it loads and displays in a timage just fine,
>using the loadfromfile method. Grrr. Please! Help! my email:
>w...@rpinet.com. Thanks.

Re:putting bitmaps INTO a dbase blob field?


On Fri, 17 Sep 1999 12:51:37 +0200, "Ivan Stefanov Tzvetkov"

Quote
<istzvet...@mbox.digsys.bg> wrote:
>Hi ! i have the same problem like you, i mean the problem with storing an
>image in blob field in paradox data base. If you have already the solution
>can you write me about it?

Have you tried the TBlobField.LoadFromFile method?

  (Table1.Fields[6] as TBlobField).LoadFromFile('c:\winnt.greenstone.bmp');

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

Re:putting bitmaps INTO a dbase blob field?


Try using Infopower's Rich-Edit component. It makes all the work for you!
But it cost's money
Regards Mogens Lenz
Quote
Ivan Stefanov Tzvetkov wrote in message

<937561754.676...@pleven.eunet.bg>...
Quote
>Hi ! i have the same problem like you, i mean the problem with storing an
>image in blob field in paradox data base. If you have already the solution
>can you write me about it?

>Bill Burns wrote in message <37DD2B77.7B45D...@rpinet.com>...
>>Many third party books, many FAQs, demo programs, etc. deal with how to
>>display graphics that are already captured and stored in a dbase or
>>paradox blob field. What about the other direction? I am trying to put
>>about 150 bitmaps into that many records in a dbf or db file, and I can
>>find little in the way of example code, at least that I can make run.
>>Are there some examples around of code to copy a bitmap to a clipboard?
>>An old FAQ shows how to paste it from the clipboard to a dbimage, like
>>putting the data ON a clipboard is too trivial to show. Or are there
>>better ways to stash graphic blob info directly into memo fields?
>>Currently, I am getting a lot of diagnostics that say my bitmap is
>>invalid when I attempt to put it in a dbf memo field, or paste to a
>>tdbimage component, and yet it loads and displays in a timage just fine,
>>using the loadfromfile method. Grrr. Please! Help! my email:
>>w...@rpinet.com. Thanks.

Other Threads