E
ebeggar
Unregistered / Unconfirmed
GUEST, unregistred user!
再说JPG图象保存到数据库(虽然我用bmp.Assign(jpg)已经搞定),为什么我使用stream,总是提示‘Bitmap image is not valid’的错误?(30分)<br />环境:D5+SQL2000+Win2000
语句:
with ADODataSet1
begin
Append;
strm:=TMemorystream.Create;
TJPEGImage(Image1.Picture.Graphic).LoadFromFile(sFName);
TJPEGImage(Image1.Picture.Graphic).SaveToStream(strm);
strm.Position := 0;
(FieldByName('PicData') as TBlobField).LoadFromStream(strm); //运行到这出错!
strm.Free;
Post;
end;
为什么我用的时候老是提示:‘Bitmap image is not valid’的错误呢?
下面是以前的帖子(富翁DreamTiger写的,应该是经过验证了的)
var
SImage: TADOBlobStream;
begin
if OpenDialog1.Execute then
begin
ADOTable1.Append;
ADOTable1.FieldByName('PhotoName').AsString := ExtractFileName(OpenDialog1.FileName);
SImage := TADOBlobStream.Create(TBlobField(ADOTable1.FieldByName('photo')), bmWrite);
SImage.LoadFromFile(OpenDialog1.Filename);
SImage.Free;
ADOTable1.Post;
end;
end;
为什么我这样用,同样有‘Bitmap image is not valid’的错误???
BTW:以上方法对bmp都没有问题!
语句:
with ADODataSet1
begin
Append;
strm:=TMemorystream.Create;
TJPEGImage(Image1.Picture.Graphic).LoadFromFile(sFName);
TJPEGImage(Image1.Picture.Graphic).SaveToStream(strm);
strm.Position := 0;
(FieldByName('PicData') as TBlobField).LoadFromStream(strm); //运行到这出错!
strm.Free;
Post;
end;
为什么我用的时候老是提示:‘Bitmap image is not valid’的错误呢?
下面是以前的帖子(富翁DreamTiger写的,应该是经过验证了的)
var
SImage: TADOBlobStream;
begin
if OpenDialog1.Execute then
begin
ADOTable1.Append;
ADOTable1.FieldByName('PhotoName').AsString := ExtractFileName(OpenDialog1.FileName);
SImage := TADOBlobStream.Create(TBlobField(ADOTable1.FieldByName('photo')), bmWrite);
SImage.LoadFromFile(OpenDialog1.Filename);
SImage.Free;
ADOTable1.Post;
end;
end;
为什么我这样用,同样有‘Bitmap image is not valid’的错误???
BTW:以上方法对bmp都没有问题!