X
xujiancai
Unregistered / Unconfirmed
GUEST, unregistred user!
如何将jpg,bmp,gif的图像保存到sql server数据库了?(用ado访问数据库)
如何对出来(jpg,bmp,gif)?使用image字段吗?
注意,不用保存路径的方法。
请告诉我详细的实现步骤?分数不高我加!
我的做法,为什么不行?请告诉我正确的做法!
procedure TForm2.SaveClick(Sender: TObject);
var Stream:Tmemorystream;
begin
if not(adoTable1.State in [dsEdit, dsInsert])
then adoTable1.Edit;
stream:=Tmemorystream.create;
image1.picture.bitmap.SaveToStream(stream);// .SaveToStream(stream);
(adoTable1.FieldByName('photo') as TBlobField).Loadfromstream(stream);
stream.free;
adoTable1.Post;
end;
<font color="#FF0000" size="6">>bmp可以
JPG,GIF不行</font></p>
procedure TForm2.ReadClick(Sender: TObject);
var
JP: TJPEGImage;
bs: TBlobStream;
begin
bs := TBlobStream.Create((adoTable1.FieldByName('p1') as TBlobField), bmRead);
jp := TJPEGImage.Create;
jp.LoadFromStream(bs);
Image1.Picture.Assign(jp);
bs.Free;
jp.Free;
end;
如何对出来(jpg,bmp,gif)?使用image字段吗?
注意,不用保存路径的方法。
请告诉我详细的实现步骤?分数不高我加!
我的做法,为什么不行?请告诉我正确的做法!
procedure TForm2.SaveClick(Sender: TObject);
var Stream:Tmemorystream;
begin
if not(adoTable1.State in [dsEdit, dsInsert])
then adoTable1.Edit;
stream:=Tmemorystream.create;
image1.picture.bitmap.SaveToStream(stream);// .SaveToStream(stream);
(adoTable1.FieldByName('photo') as TBlobField).Loadfromstream(stream);
stream.free;
adoTable1.Post;
end;
<font color="#FF0000" size="6">>bmp可以
JPG,GIF不行</font></p>
procedure TForm2.ReadClick(Sender: TObject);
var
JP: TJPEGImage;
bs: TBlobStream;
begin
bs := TBlobStream.Create((adoTable1.FieldByName('p1') as TBlobField), bmRead);
jp := TJPEGImage.Create;
jp.LoadFromStream(bs);
Image1.Picture.Assign(jp);
bs.Free;
jp.Free;
end;