How to save a Word document to the database?

Category: Delphi -> VCL/Component Author: woshuoguoma Date: 2005-07-12 12:21:30
 
woshuoguoma
2005-07-12 12:21:30
I now can not solve a problem is:
I want a WORD document as a field in a database table, saved to the database inside.
do not know whether this can be achieved? If so, how should it do?
sunyu444
2005-07-12 12:24:06
var
FieldCont: TBlobStream;
filestm: TFileStream;
begin
ADOQuery1.Open;
FileStm: = TFileStream.Create ('D: \ 11.doc', fmCreate);
FieldCont: = TBlobStream (ADOQuery1.CreateBlobStream (ADOQuery1.FieldByName ('content'), bmRead));
FileStm.CopyFrom (FieldCont, FieldCont.size);
FileStm . Free;
FieldCont.Free;
end;
jackentir001
2005-07-12 12:41:45
Table Structure: testword
autoid int automatically increase
fdname varchar (50)
fdtext image
save file code:
procedure TForm1.Button1Click (Sender: TObject);
begin
; if OpenDialog1.Execute then
begin
if not ADOQuery1.Active then ADOQuery1.Open;
; ADOQuery1.Append;
ADOQuery1fdname.Value: = ExtractFileName (OpenDialog1.FileName);
(ADOQuery1. FieldByName ('fdtext') as TBlobField). LoadFromFile (OpenDialog1.filename);
ADOQuery1.Post;
end;
end;

open file code:
procedure TForm1.Button2Click (Sender: TObject);
begin
(ADOQuery1.FieldByName ('fdtext') as TBlobField). savetoFile (ExtractFileDir (Application.ExeName) + ADOQuery1fdname.value);
shellexecute (handle, nil, pchar (ADOQuery1fdname.value), nil, nil , sw_shownormal);
end;

need shellapi unit.

to sub it certainly can. Whether WORD, EXCLE, but also can be used in the JPG .
www7156
2005-07-12 12:51:35
uses db

tblobfield (ADOQUERY1. FIELDBYNAME ('field name')). loadformfile ('c: \ abc.doc');
hwx460436113
2005-07-12 12:58:25
and save the image to the database is the same. Such a code. Lot.
hr_hs
2005-07-12 13:07:23
that it is not necessary, if it is inside everything, save the file, then

diameter incredible
benhaoyoo
2005-07-12 13:15:32
ADOQuery1fdname pass compiler how ah?