G
gztoms
Unregistered / Unconfirmed
GUEST, unregistred user!
本人想用Delphi+ADO+SQL Server来存储读取任何格式的文件,比如文本格式(DOC,TXT等),
图片格式等等,我认为用流的方法应该可以解决这个问题,曾经试过:
procedure TForm1.Button1Click(Sender: TObject);
var
Stream: TADOBlobStream;
MemoryStream : TMemoryStream;
begin
ADOQuery1.Open;
ADOQuery1.Edit;
ADOQuery1.Append;
MemoryStream := TMemoryStream.Create;
MemoryStream.LoadFromFile('file.doc');
stream :=
TADOBlobStream.Create(ADOQuery1.FieldByName('files')as TBlobField,bmReadWrite);
//上面一句话出错了
MemoryStream.SaveToStream(stream);
stream.free;
ADOQuery1.Post;
MemoryStream.Free;
end;
字段files的类型是binary,但是不能同过,请各位大侠指点指点,
请给点主意,最好给一段程序,先谢谢了!
图片格式等等,我认为用流的方法应该可以解决这个问题,曾经试过:
procedure TForm1.Button1Click(Sender: TObject);
var
Stream: TADOBlobStream;
MemoryStream : TMemoryStream;
begin
ADOQuery1.Open;
ADOQuery1.Edit;
ADOQuery1.Append;
MemoryStream := TMemoryStream.Create;
MemoryStream.LoadFromFile('file.doc');
stream :=
TADOBlobStream.Create(ADOQuery1.FieldByName('files')as TBlobField,bmReadWrite);
//上面一句话出错了
MemoryStream.SaveToStream(stream);
stream.free;
ADOQuery1.Post;
MemoryStream.Free;
end;
字段files的类型是binary,但是不能同过,请各位大侠指点指点,
请给点主意,最好给一段程序,先谢谢了!