Solved

DBGrid problem

Posted on 2006-10-24
3
175 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
3 Comments
 
LVL 17

Expert Comment

by:TheRealLoki
Comment Utility
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
Comment Utility
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
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

763 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

12 Experts available now in Live!

Get 1:1 Help Now