Solved

DBGrid problem

Posted on 2006-10-24
3
180 Views
Last Modified: 2010-04-04
Im using dbgrid to show pictures from database, and Labels to show picture balance

but every picture has wrong balance from database
First picture balance 2000, second picture balance 100 - BUT I SEE 1000 :/

if i click on picture balance corrects to 100

How to remove this error?

procedure TForm1.DBCtrlGrid1PaintPanel(DBCtrlGrid: TDBCtrlGrid;
  Index: Integer);
begin
  JPEG := TJPEGImage.Create;
  tmp  := TMemoryStream.Create;
  try

    if AdoQuery1.FieldByName('balansas').Value = null then Label20.Caption := ''
    else Label20.Caption := AdoQuery1.FieldByName('balansas').Value;

    if not TBlobField(ADOQuery1.FieldByName('nuotrauka')).IsNull then  //is there a picture?
    begin
      TBlobField(ADOQuery1.Fieldbyname('nuotrauka')).SaveToStream(tmp);
      tmp.Seek(0, soFromBeginning);
      JPEG.LoadFromStream(tmp);
      DBImage1.Picture.Assign(JPEG);
      DBImage1.visible := true;
    end
      else
    begin
      if DBImage1.Picture <> nil then
      begin
        DBImage1.Picture := nil;
      end;
    end;
  finally
    JPEG.Free;
    tmp.Free;
  end;
end;
0
Comment
Question by:selas
[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
3 Comments
 
LVL 17

Expert Comment

by:TheRealLoki
ID: 17800675
what's a balance?
can you show us your SQL?
is it perhaps using the wrong kind of "join"?
Do you have an event (eg. image1.OnChange) that is setting the balance (incorrectly) when you load the image from the blob?
(perhaps change your procedure to do
    if AdoQuery1.FieldByName('balansas').Value = null then Label20.Caption := ''
    else Label20.Caption := AdoQuery1.FieldByName('balansas').Value;
at the end instead)
0
 
LVL 17

Accepted Solution

by:
mokule earned 500 total points
ID: 17803449
Try to change this
   if AdoQuery1.FieldByName('balansas').Value = null then Label20.Caption := ''
    else Label20.Caption := AdoQuery1.FieldByName('balansas').Value;
into this
   if AdoQuery1.FieldByName('balansas').IsNull then Label20.Caption := ''
    else Label20.Caption := AdoQuery1.FieldByName('balansas').Value;
0
 
LVL 6

Expert Comment

by:wimmeyvaert
ID: 17804192
Or maybe you can change :

if AdoQuery1.FieldByName('balansas').Value = null then Label20.Caption := ''

into

if AdoQuery1.FieldByName('balansas').Value = UnAssigned then Label20.Caption := ''


Best regards,

The Mayor.
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

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

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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

759 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