C
cpf246
Unregistered / Unconfirmed
GUEST, unregistred user!
我在处理图片的存取的时候,用的是一个通用方式,但是我始终不能把图片存进数据库,大侠们帮我分析下是怎么回事,不慎感激!
ClientDataSet.Close;
ClientDataSet.CommandText := 'Select ID, Photo, FileExt from student where ID="' + FID + '" ';
ClientDataSet.Open;
ClientDataSet.Edit;
if ImagePhoto.Picture.Graphic <> nil then
begin
FMemoryStream := TMemoryStream.Create;
Jpeg := TJPEGImage.Create;
Jpeg.Assign(ImagePhoto.Picture.Graphic);
Jpeg.SaveToStream(FMemoryStream);
FMemoryStream.Position := 0;
TBlobField(ClientDataSet.FieldByName('Photo')).LoadFromStream(FMemoryStream);
ClientDataSet.FieldByName('FileExt').AsString := FileExt;
Jpeg.Free;
FMemoryStream.Free;
end;
ClientDataSet.Post;
ClientDataSet.ApplyUpdates(0);
同样的代码我在另外一个系统中运行正常,图片的存取也没问题,单我用到这里就是不行,期待!!![][]
ClientDataSet.Close;
ClientDataSet.CommandText := 'Select ID, Photo, FileExt from student where ID="' + FID + '" ';
ClientDataSet.Open;
ClientDataSet.Edit;
if ImagePhoto.Picture.Graphic <> nil then
begin
FMemoryStream := TMemoryStream.Create;
Jpeg := TJPEGImage.Create;
Jpeg.Assign(ImagePhoto.Picture.Graphic);
Jpeg.SaveToStream(FMemoryStream);
FMemoryStream.Position := 0;
TBlobField(ClientDataSet.FieldByName('Photo')).LoadFromStream(FMemoryStream);
ClientDataSet.FieldByName('FileExt').AsString := FileExt;
Jpeg.Free;
FMemoryStream.Free;
end;
ClientDataSet.Post;
ClientDataSet.ApplyUpdates(0);
同样的代码我在另外一个系统中运行正常,图片的存取也没问题,单我用到这里就是不行,期待!!![][]