We help IT Professionals succeed at work.
Get Started

I am trying to open a picture in my data base

143 Views
Last Modified: 2015-09-28
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
Comment
Watch Question
Oracle dba
CERTIFIED EXPERT
Top Expert 2009
Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE