Avatar of Frankenfich
Frankenfich
 asked on

I am trying to open a picture in my data base

Hello i am trying to open a picture that is in the ms database. Everything links fine the data base shows all the information. Except when i press on the button to open the picture associated with the Name of the animal.
Please can someone help ?
 TFrmMammals.Button1Click(Sender: TObject);
 Var
 S : TMemoryStream ;
 graphic : TGraphic ;
 GraphicType : String ;


begin

   ADOQuery1.Close   ;
   ADOQuery1.SQL.Text := 'select Male from Mammals where EnglishName = ''' + DBLookupComboBox1.Text + ''''  ;
     ADOQuery1.Open    ;


   S := TMemoryStream.Create;
   Try
   TBlobField(ADOQuery1.FieldByName('Male')).SaveToStream(S);
   S.Position := 0 ;

    GraphicType := ADOQuery1.fieldbyName('Male').AsString ;

  if
   GraphicType = 'BNP'
   Then
 graphic := TBitmap.Create;

 ADOQuery1.fieldbyName('Male').AsString := 'Bnp' ;
  except
 If GraphicType = 'Jpg'
  then
  graphic := TJPEGImage.Create
    else

   try
    Image1.Picture.Assign(graphic);
    finally
    graphic.Free;
    S.free ;
    end;
   end ;


 ADOQuery1.fieldbyName('Male').AsString := 'Bnp' ;
This is where the error is and it states class Edatabase error with message ' adoQuery : Dataset not in edit or insert mode'.
Kind regards
Frank
DelphiProgramming Languages-Other

Avatar of undefined
Last Comment
Frankenfich

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Geert G

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Geert G

Frankenfich

ASKER
Thanks Yes i know caps does influence change it. and in my case it will only be jpg and bitmap. Thanks for the help i will read over my coding again and edit it some more.  I am still very new in this will try and see if i can correct it
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy