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);
 S : TMemoryStream ;
 graphic : TGraphic ;
 GraphicType : String ;


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

   S := TMemoryStream.Create;
   S.Position := 0 ;

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

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

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

    S.free ;
   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
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Geert GOracle dbaCommented:
I'm not sure what graphic type a "BNP" is
but i do know of a type called: BMP, also known as BITMAP
you messed up the graphic type, or is that a typo ?

next, please try and indent correctly
it makes the code more readable

and when you add code, select it and use the Code in the editor
it'll move the code into a small window within your question
and format it a little

next, you'll need to understand directions
imagine on the Left is your database, on the Right is your app

Going from Left to Right is called selecting from the database (or reading)
Going from Right to Left is called inserting/updating the database (or writing)

you've got the directions messed up
here you are reading =
GraphicType := ADOQuery1.fieldbyName('Male').AsString ;

Here you are writing to the database, without setting it in edit mode first
 ADOQuery1.fieldbyName('Male').AsString := 'Bnp' ;
because you didn't set the query in editmode, you get the error

are you aware your 'BNP' and 'Bnp' are different in case ?
This will potentially cause mismatches too ... besides the typo off course

are you trying to open a Bitmap or a Jpeg ?
are you sure there is only 2 types of pictures in that database ?

because of the very odd indenting in your code, it's very difficult to understand what you are doing

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Geert GOracle dbaCommented:
FrankenfichAuthor Commented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.