selas
asked on
DBGrid problem
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.DBCtrlGrid1PaintPan el(DBCtrlG rid: TDBCtrlGrid;
Index: Integer);
begin
JPEG := TJPEGImage.Create;
tmp := TMemoryStream.Create;
try
if AdoQuery1.FieldByName('bal ansas').Va lue = null then Label20.Caption := ''
else Label20.Caption := AdoQuery1.FieldByName('bal ansas').Va lue;
if not TBlobField(ADOQuery1.Field ByName('nu otrauka')) .IsNull then //is there a picture?
begin
TBlobField(ADOQuery1.Field byname('nu otrauka')) .SaveToStr eam(tmp);
tmp.Seek(0, soFromBeginning);
JPEG.LoadFromStream(tmp);
DBImage1.Picture.Assign(JP EG);
DBImage1.visible := true;
end
else
begin
if DBImage1.Picture <> nil then
begin
DBImage1.Picture := nil;
end;
end;
finally
JPEG.Free;
tmp.Free;
end;
end;
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.DBCtrlGrid1PaintPan
Index: Integer);
begin
JPEG := TJPEGImage.Create;
tmp := TMemoryStream.Create;
try
if AdoQuery1.FieldByName('bal
else Label20.Caption := AdoQuery1.FieldByName('bal
if not TBlobField(ADOQuery1.Field
begin
TBlobField(ADOQuery1.Field
tmp.Seek(0, soFromBeginning);
JPEG.LoadFromStream(tmp);
DBImage1.Picture.Assign(JP
DBImage1.visible := true;
end
else
begin
if DBImage1.Picture <> nil then
begin
DBImage1.Picture := nil;
end;
end;
finally
JPEG.Free;
tmp.Free;
end;
end;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Or maybe you can change :
if AdoQuery1.FieldByName('bal ansas').Va lue = null then Label20.Caption := ''
into
if AdoQuery1.FieldByName('bal ansas').Va lue = UnAssigned then Label20.Caption := ''
Best regards,
The Mayor.
if AdoQuery1.FieldByName('bal
into
if AdoQuery1.FieldByName('bal
Best regards,
The Mayor.
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('bal
else Label20.Caption := AdoQuery1.FieldByName('bal
at the end instead)