Solved

database problem with delphi progra

Posted on 2003-12-02
9
354 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
QRReport  TQrmemo vertical stretching 1 45
Making delphi communicate with a c# service 16 103
Delphi inherited method 6 68
When i run adoquery my application freezes 26 165
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

776 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