Solved

database problem with delphi progra

Posted on 2003-12-02
9
352 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
Comment Utility
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
Comment Utility
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
Comment Utility
oops there should be a dot :-))

Dataset,FieldByName -> Dataset.FieldByName
0
 
LVL 1

Expert Comment

by:roknjohn
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 27

Expert Comment

by:kretzschmar
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
ok and i want to read from the same table from the databse
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now