Link to home
Start Free TrialLog in
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
ASKER CERTIFIED SOLUTION
Avatar of Geert G
Geert G
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Frankenfich
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