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(S ender: 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.Field ByName('Ma le')).Save ToStream(S );
S.Position := 0 ;
GraphicType := ADOQuery1.fieldbyName('Mal e').AsStri ng ;
if
GraphicType = 'BNP'
Then
graphic := TBitmap.Create;
ADOQuery1.fieldbyName('Mal e').AsStri ng := 'Bnp' ;
except
If GraphicType = 'Jpg'
then
graphic := TJPEGImage.Create
else
try
Image1.Picture.Assign(grap hic);
finally
graphic.Free;
S.free ;
end;
end ;
ADOQuery1.fieldbyName('Mal e').AsStri ng := '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
Please can someone help ?
TFrmMammals.Button1Click(S
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.Field
S.Position := 0 ;
GraphicType := ADOQuery1.fieldbyName('Mal
if
GraphicType = 'BNP'
Then
graphic := TBitmap.Create;
ADOQuery1.fieldbyName('Mal
except
If GraphicType = 'Jpg'
then
graphic := TJPEGImage.Create
else
try
Image1.Picture.Assign(grap
finally
graphic.Free;
S.free ;
end;
end ;
ADOQuery1.fieldbyName('Mal
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
https://www.experts-exchange.com/questions/24179974/Upload-Download-picture-from-to-SQL-server-DB.html