为何不能存入扩展名为.JPG格式的图片?
数据库使用的是 sqlserver2000
图片字段类型为 image
如果存入的是.bmp格式的就没有问题,如果是.jpg格式的就会出现以下错误,请各位大哥指教!
procedure TForm1.Button1Click(Sender: TObject);
var
strm:tmemorystream;
ext:string;
JPEGImage:TJPEGImage;
begin
if image1.picture.Graphic <> nil then //避免image1中无图像保存出错
begin
ext:=extractfileext(openpicturedialog1.FileName ); //取出文件的扩展名
strm := tmemorystream.Create ;
try
image1.Picture.Graphic.SaveToStream(strm);
adoquery1.Append;
strm.Position :=0;
tblobfield(adoquery1.FieldByName('image')).LoadFromStream(strm);//执行到此处就出现“Bitmap images is not valid”的错误
adoquery1.Post ;
finally
strm.Free ;
end;
end;
end;