Home > Back-end >  Remove database word2010 and open problems
Remove database word2010 and open problems

Time:10-02

Master:
I put the word document directly to the database, when reading will open, but will quote file is damaged, need to repair procedure is as follows:
The begin
MyFile:=TFileStream. Create (' c: \ temp. TMP, fmCreate);
With adoQuery1 do
The begin
Stream:=TadoBlobStream. The Create
(FieldByName (' text ') as TBlobField, bmRead);
MemSize:=Stream. Size;
Inc (MemSize);
Buffer:=AllocMem (MemSize);
Try
Stream. Read (Buffer ^, MemSize);
MyFile. Write (Buffer ^, MemSize);
The finally
MyFile. Free;
Stream. Free;
end;
end;
If FileExists (' c: \ temp. DOCX)
Then
DeleteFile (' c: \ temp. DOCX);
If FileExists (' c: \ temp. TMP)
Then
The begin
RenameFile (' c: \ temp. TMP ', 'c: \ temp. Docx);

ShellExecute (handle, the 'open', pchar (' c: \ temp. Docx '), ' ', ' ', SW_SHOWNORMAL)
end;

end;

CodePudding user response:

After the load, Stream. Position:=0
  • Related