For example, if the variable Buffer is of type PChar and contains binary data read from a file, the contents of Buffer are directly assigned to the BLOB parameter using the AsBlob property:
Query1.Params[0].AsBlob := Buffer;
Note: Applications seldom need to read AsBlob because Blob fields cant be used as output parameters.
Query1.Params[0].AsBlob := Buffer;
Note: Applications seldom need to read AsBlob because Blob fields cant be used as output parameters.
procedure TForm1.Button1Click(Sender: TObject);
var
Stream1: TBlobStream;
Stream2: TStream;
begin
Stream1 := TBlobStream.Create(Table1Notes, bmRead);
try
ClientDataSet1.Edit;
{ here抯 a different way to create a blob stream }
Stream2 := ClientDataSet1.CreateBlobStream(ClientDataSet1.FieldByName('Res'), bmReadWrite);
try
Stream2.CopyFrom(Stream1, Stream1.Size);
ClientDataSet1.Post;
finally
Stream2.Free;
end; finally
Stream1.Free;
end;
end;
,tmemorystream,实际上他们也是一个内存区域,只是封装得更好而已
我觉得用buffer就够了!
如果要从tmemorystream之类获得buffer,
调用TmemoryStream.writebuffer(Buffer,count);
在把这个buffer传过去
IBQuery1.ParamByName('BlobFieldName').LoadFromStream(MemoryStream,ftBlob);