Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

database problem with delphi progra

Posted on 2003-12-02
9
Medium Priority
?
360 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 315 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 315 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

636 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