Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 03-23-2005, 10:15 PM
quickfix76 quickfix76 is offline
Member
 
Join Date: Mar 2005
Posts: 36
Default How To Write exception for Stream Read Error?

Hi there,

Im trying to incoporate "Try Except" [but not sure how or where to put it my code] to stop a message box popping up stating "Stream Read Error" when the user trys to get the image from the database but there is no image for that file.

I have a function that enables me to load jpeg images from a database.
It works correctly except when there is no image to load I get the abovementioned error.

Here is the code that calls the image(where or should I put the 'Try, Except'):



procedure TForm1.ShowImage(Sender: TObject);
var
bS : TADOBlobStream;
Pic : TJpegImage;
begin
bS := TADOBlobStream.Create
(AdoTable1Image, bmRead);
try
bS.Seek(JpegStartsInBlob(AdoTable1Image),
soFromBeginning);
Pic:=TJpegImage.Create;
try
Pic.LoadFromStream(bS);
{ ADOImage.Picture.Graphic:=Pic; }
Form2.Image1.Picture.Graphic := Pic;
Form2.visible := true;
Form2.Image1.Width := Form2.Image1.Picture.Width;
Form2.Image1.Height := Form2.Image1.Picture.Height;
Form2.Width := Form2.Image1.Picture.Width + 6;
Form2.Height := Form2.Image1.Picture.Height + 28;
finally
Pic.Free;
end;
finally
bS.Free
end;
end;
Reply With Quote
  #2  
Old 03-24-2005, 02:25 AM
autocorect autocorect is offline
Senior Member
 
Join Date: Mar 2005
Posts: 725
Default RE: How To Write exception for Stream Read Error?

Finally is not good in this case use Except.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 11:16 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.