读取:
var
MS:TMemoryStream;
begin
........
........
MS:=TMemoryStream(DataSet1.CreateBlobStream(DataSet.FieldByName('Field1),bmRead));
.....
现在已经将Field1字段转换成TMemoryStream类型了,保存在MS中了,
希望对你有所帮助。
插入:
TBlobField(Table.FieldbyName('xxx')).LoadFromFile();
也可以用LoadFromStream
例:
var
MS: TMemoryStream;
begin
//如果不在修改或增加状态,改变状态
if not (table1.State in [dsInsert, dsEdit]) then
table1.Insert;
MS := TMemoryStream.Create();
try
Image1.Picture.Bitmap.SaveToStream(MS);
TBlobField(Table.FieldbyName('xxx')).LoadFromStream(MS);
finally
MS.Free;
end;
Table1.Post; //提交数据
end;
阅读(3788) | 评论(0) | 转发(0) |