Solved

database problem with delphi progra

Posted on 2003-12-02
9
355 Views
Last Modified: 2010-04-05
hi i wrote a program which generates buttons with the fields from the database but i would really like that button generation program to generate pictures instead of the text field to do exacly teh same generate buttons  but wit6h the pictures.
i cannot post it anywhere but if somebody feels up to the task the all they have to do is supply me with the e-mail and i will send that file to them
then afterwe done we will post the source code
i am using access database for now
thanks
ps.picture generation programm which will take the pictures stored in the databse under the text fields
thanks
0
Comment
Question by:george_4
  • 4
  • 3
  • 2
9 Comments
 
LVL 1

Expert Comment

by:roknjohn
ID: 9859769
Here's the best way I've found to read/write images (or any blob for that matter) to MS Access or MS SQL databases, using ADO:  

procedure LoadBlobStream(Stream : TStream; Blob : TBlobField);
var
  dbStream : TADOBlobStream;
begin
  try
    dbStream := TADOBlobStream.Create(Blob,bmRead);
    dbStream.SaveToStream(Stream);
  finally
    dbStream.Free;
  end;
end;

procedure SaveBlobStream(Stream : TStream; Blob : TBlobField);
var
  dbStream : TADOBlobStream;
begin
  with Blob.DataSet do begin
    if State = dsBrowse then
      Edit;
    try
      dbStream := TADOBlobStream.Create(Blob,bmWrite);
      dbStream.LoadFromStream(Stream);
    finally
      dbStream.Free;
    end;
  end;
end;


What kind of button control did you have in mind?
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 9859957
it goes easier, via typecasting like

//store -> dataset must be in edit/insert-mode
TBlobField(Dataset,FieldByName('BlobFieldName')).LoadFromFile('FileNameHere); //or LoadFromStream

//get
TBlobField(Dataset,FieldByName('BlobFieldName')).SaveToFile('FileNameHere); //or SaveToStream

meikl ;-)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 9859971
oops there should be a dot :-))

Dataset,FieldByName -> Dataset.FieldByName
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 1

Expert Comment

by:roknjohn
ID: 9860024
I've had problems in the past when I didn't use a TADOBlobStream.  

I think there is a discussion about it on delphi.about.com, I'll have to find the link.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 9860074
well, the typecast causes,
that vcl-intern the blobstream is created and freed,
like your code above (which looks good)

there may a problem with persistent fields
(which is not used by this typecast)

would be nice, if you find the link, roknjohn

meikl ;-)
0
 
LVL 1

Assisted Solution

by:roknjohn
roknjohn earned 105 total points
ID: 9860167
Well, this is one discussion, but not the one I had in mind..

http://delphi.about.com/library/weekly/aa030601a.htm

I'll have to look back at the research I did last year when developing a document imaging system with a MSSQL backend.  For some reason, the TADOBlobStream was the only way to go.
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 105 total points
ID: 9860220
well, thats a discussion about the oleobject-field-type of access
(i personal dislike this kind of fieldtype with oleinformation-header
and use it as ordinary blobfield without oleinformation-header,
which has as fallback, that the cannot diplayed with the access-
frontend)

meikl ;-)
0
 

Author Comment

by:george_4
ID: 9862061
ok
but i already have it generate buttons from the text fields now i want that program
to read the pictures beside instead of the text field and i aslo have no idea how to put it in access
i can send the source if anybody wants to take a look
or better i will post it tonight once i get home
thanks
0
 

Author Comment

by:george_4
ID: 9863950
ok and i want to read from the same table from the databse
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi XE10, MySQL Query 4 167
FMX enumerated colours 2 119
drawing animated level bar based on numbers 3 104
Firemonkey webbrowser scrollbars ? 1 50
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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

820 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