1、请问怎么把word,excel文档,还有其它图像文件保存在数据库中
2、怎么把保存在数据库中的word,excel文档内容显示在memo上面
3、怎么用相应的格式直接打开保存在数据库中的文档文件,例如用word打开保存在数据库中的word文件

解决方案 »

  1.   

    1.打开word文件。
        procedure TfjfsglForm.SpeedButton4Click(Sender: TObject);
        var
        MSWord: Variant;
        str:string; 
        begin
          if trim(DataModule1.adoquery27.fieldbyname('fjmc').asstring)<>'' then
          begin
            str:=trim(DataModule1.ADOQuery27.fieldbyname('fjmc').AsString);
            MSWord:= CreateOLEObject('Word.Application');//
            MSWord.Documents.Open('d:\Program Files\Common Files\Sfa\'+str, True);//
            MSWord.Visible:=1;//
            str:='';
            MSWord.ActiveDocument.Range(0, 0);//
            MSWord.ActiveDocument.Range.InsertAfter(str);//?úWord?D???ó×?·?'Title'
            MSWord.ActiveDocument.Range.InsertParagraphAfter;
          end
          else
          showmessage('');
        end;
    (2)word文件传入和传出数据库。
        uses IdGlobal;
        procedure TdjhyForm.SpeedButton2Click(Sender: TObject);
        var
        sfilename:string;
        function BlobContentTostring(const Filename:string):string;
        begin
          with Tfilestream.Create(filename,fmopenread)  do
          try
            setlength(result,size);
            read(pointer(result)^,size);
          finally
            free;
          end;
        end;
        begin
          if opendialog1.Execute then
          begin
            sfilename:=opendialog1.FileName;
            DataModule1.ADOQuery14.Edit;
            DataModule1.ADOQuery14.FieldByName('word').AsString:=blobcontenttostring(sfilename);
            DataModule1.ADOQuery14.Post;
          end;
        end;
        procedure TdjhyForm.SpeedButton1Click(Sender: TObject);
        var
        sfilename:string;
        bs:Tadoblobstream;
        begin
          bs:=Tadoblobstream.Create(TBLOBfield(DataModule1.ADOQuery14.FieldByName('word')),bmread);
          try
            sfilename:=extractfilepath(application.ExeName)+trim(DataModule1.adoquery14.fieldbyname('hybh').AsString);
            sfilename:=sfilename+'.'+'doc';
            bs.SaveToFile(sfilename);
            try
              djhyopenform:=Tdjhyopenform.Create(self);
              djhyopenform.olecontainer1.CreateObjectFromFile(sfilename,false);
              djhyopenform.OleContainer1.Iconic:=true;
              djhyopenform.ShowModal;
            finally
              djhyopenform.Free;
            end;
          finally
            bs.free;
          end;
        end;