[Delphi] 如何用DELPHI實現把WORD、EXCEL和圖片等儲存到資料庫中

來源出處:
https://www.itread01.com/content/1548048812.html

用image欄位儲存這些文件。   
  var   
      word_stream:   TMemoryStream;   
      filename:   string;   
  begin   
      if   odgDoc.Execute   then//odgDoc:OpenDialog   
      begin   
          filename   :=   ExtractFileName(odgDoc.FileName);   
          word_stream   :=   TMemoryStream.Create;   
          word_stream.LoadFromFile(odgDoc.FileName);   
          word_stream.Position   :=   0;   
          cdsPACT.Append   
          cdsPACT.FieldByName(‘DocName’).Value   :=   filename;   
          TBlobField(cdsPACT.FieldByName(‘PactText’)).LoadFromStream(word_stream);   
          cdsPACT.Post;   
          word_stream.Free;   
      end;   
  end; 

發表留言