Q&A

  • RichEdit의 내용을 DB에 서식을 포함하여 저장하는 방법 좀 알려주세요.
여기에 있는 무수한 글을 읽어보며 정답을 찾기 위해 노력했지만

저와 같은 고민을 하고 있는 분들의

질문은 있으나 답이 없어 죄송스럽지만 글을 올립니다.

상당히 간단한 문제이니 한번만 봐 주시길 바랍니다.



Richedit에서 작성된 문서를 Oracle DB에 저장할려고 했는데....



1. 첫번째 시도

DataModule_Report.Query_ReportContents.ParamByName('contents').AsString :=

richedit_Editor.Lines.Text;



이렇게 한 후 updatesql을 이용해 DB에 저장을 하니 서식은 온데 간데없고

순수 text만 저장이 되더군요.



2. 두번째 시도

그래서 여기 있는 글들을 읽어보고 다음과 같이 하였으나 여전히 에러가

생기며 안되네요.(이 방법이 맞는지 모르지만 시도 해봤습니다)



var

ContentsStream : TMemoryStream;

begin

ContentsStream := TMemoryStream.Create;

richedit_Editor.Lines.SaveToStream(ContentsStream);



DataModule_Report.Query_ReportContents.Close;

DataModule_Report.Query_ReportContents.SQL.Clear;

DataModule_Report.Query_ReportContents.SQL.Add('update report');

DataModule_Report.Query_ReportContents.SQL.ADD('set contents=:contents');

DataModule_Report.Query_ReportContents.SQL.ADD('where obj_id = :obj_id');

DataModule_Report.Query_ReportContents.ParamByName('contents').LoadFromStream

:= (ContentsStream, ftBlob);

DataModule_Report.Query_ReportContents.ParamByName('obj_id').AsString

:= '1234';

DataModule_Report.Query_ReportContents.ExecSQL;



도대체 어떻게 해야 서식을 포함한 모든 내용을 db에 저장 할 수

있을 까요?



고수님 도와주세요.......





3  COMMENTS
  • Profile
    김일영 2001.10.25 13:33
    델파이 팁모아에서 'File'로 검색했습니다.

    아마 이것이면 충분할 것 같군요.



    http://www.delphi.co.kr/cgi-bin/cwb/CrazyWWWBoard.cgi?mode=read&num=1162&db=tips&fval=File&backdepth=1



    검색을 생활화합시다.







    난..안돼 wrote:

    > 여기에 있는 무수한 글을 읽어보며 정답을 찾기 위해 노력했지만

    > 저와 같은 고민을 하고 있는 분들의

    > 질문은 있으나 답이 없어 죄송스럽지만 글을 올립니다.

    > 상당히 간단한 문제이니 한번만 봐 주시길 바랍니다.

    >

    > Richedit에서 작성된 문서를 Oracle DB에 저장할려고 했는데....

    >

    > 1. 첫번째 시도

    > DataModule_Report.Query_ReportContents.ParamByName('contents').AsString :=

    > richedit_Editor.Lines.Text;

    >

    > 이렇게 한 후 updatesql을 이용해 DB에 저장을 하니 서식은 온데 간데없고

    > 순수 text만 저장이 되더군요.

    >

    > 2. 두번째 시도

    > 그래서 여기 있는 글들을 읽어보고 다음과 같이 하였으나 여전히 에러가

    > 생기며 안되네요.(이 방법이 맞는지 모르지만 시도 해봤습니다)

    >

    > var

    > ContentsStream : TMemoryStream;

    > begin

    > ContentsStream := TMemoryStream.Create;

    > richedit_Editor.Lines.SaveToStream(ContentsStream);

    >

    > DataModule_Report.Query_ReportContents.Close;

    > DataModule_Report.Query_ReportContents.SQL.Clear;

    > DataModule_Report.Query_ReportContents.SQL.Add('update report');

    > DataModule_Report.Query_ReportContents.SQL.ADD('set contents=:contents');

    > DataModule_Report.Query_ReportContents.SQL.ADD('where obj_id = :obj_id');

    > DataModule_Report.Query_ReportContents.ParamByName('contents').LoadFromStream

    > := (ContentsStream, ftBlob);

    > DataModule_Report.Query_ReportContents.ParamByName('obj_id').AsString

    > := '1234';

    > DataModule_Report.Query_ReportContents.ExecSQL;

    >

    > 도대체 어떻게 해야 서식을 포함한 모든 내용을 db에 저장 할 수

    > 있을 까요?

    >

    > 고수님 도와주세요.......

    >

    >

  • Profile
    난..안돼 2001.10.25 20:17
    답변에 감사합니다.



    그런데 저는 파일로 저장하는 것이 아니라

    RichEdit의 내용을 DB Table에 넣고 싶거든요.



    이건 어떻게 해야되죠? 팁이라든가 Q&A 다 뒤져

    봤는데 찾을 수가 없었어요....



    부탁 할께요.... 고수님....









    김일영 wrote:

    > 델파이 팁모아에서 'File'로 검색했습니다.

    > 아마 이것이면 충분할 것 같군요.

    >

    > http://www.delphi.co.kr/cgi-bin/cwb/CrazyWWWBoard.cgi?mode=read&num=1162&db=tips&fval=File&backdepth=1

    >

    > 검색을 생활화합시다.

    >

    >

    >

    > 난..안돼 wrote:

    > > 여기에 있는 무수한 글을 읽어보며 정답을 찾기 위해 노력했지만

    > > 저와 같은 고민을 하고 있는 분들의

    > > 질문은 있으나 답이 없어 죄송스럽지만 글을 올립니다.

    > > 상당히 간단한 문제이니 한번만 봐 주시길 바랍니다.

    > >

    > > Richedit에서 작성된 문서를 Oracle DB에 저장할려고 했는데....

    > >

    > > 1. 첫번째 시도

    > > DataModule_Report.Query_ReportContents.ParamByName('contents').AsString :=

    > > richedit_Editor.Lines.Text;

    > >

    > > 이렇게 한 후 updatesql을 이용해 DB에 저장을 하니 서식은 온데 간데없고

    > > 순수 text만 저장이 되더군요.

    > >

    > > 2. 두번째 시도

    > > 그래서 여기 있는 글들을 읽어보고 다음과 같이 하였으나 여전히 에러가

    > > 생기며 안되네요.(이 방법이 맞는지 모르지만 시도 해봤습니다)

    > >

    > > var

    > > ContentsStream : TMemoryStream;

    > > begin

    > > ContentsStream := TMemoryStream.Create;

    > > richedit_Editor.Lines.SaveToStream(ContentsStream);

    > >

    > > DataModule_Report.Query_ReportContents.Close;

    > > DataModule_Report.Query_ReportContents.SQL.Clear;

    > > DataModule_Report.Query_ReportContents.SQL.Add('update report');

    > > DataModule_Report.Query_ReportContents.SQL.ADD('set contents=:contents');

    > > DataModule_Report.Query_ReportContents.SQL.ADD('where obj_id = :obj_id');

    > > DataModule_Report.Query_ReportContents.ParamByName('contents').LoadFromStream

    > > := (ContentsStream, ftBlob);

    > > DataModule_Report.Query_ReportContents.ParamByName('obj_id').AsString

    > > := '1234';

    > > DataModule_Report.Query_ReportContents.ExecSQL;

    > >

    > > 도대체 어떻게 해야 서식을 포함한 모든 내용을 db에 저장 할 수

    > > 있을 까요?

    > >

    > > 고수님 도와주세요.......

    > >

    > >

  • Profile
    김일영 2001.10.26 02:05
    제 환경에서 테스트는 해볼수 없었지만,

    여기저기 소스를 꿰다 붙여서 만들어 봤습니다.

    DB로 저장하는 부분만 만들었습니다.

    읽어오는 것은 거꾸로 하시면 되겠죠.

    아마 될거라고 생각합니다.

    수고하세요.



    unit Unit1;



    interface



    uses

    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

    Dialogs, StdCtrls, DB, Grids, DBGrids, DBTables;



    type

    TForm1 = class(TForm)

    Database1: TDatabase;

    Query1: TQuery;

    UpdateSQL1: TUpdateSQL;

    Query1EDATE: TStringField;

    Query1FNAME: TStringField;

    Query1FILES: TBlobField;

    DBGrid1: TDBGrid;

    DataSource1: TDataSource;

    Button1: TButton;

    procedure Button1Click(Sender: TObject);

    private

    { Private declarations }

    public

    { Public declarations }

    end;



    var

    Form1: TForm1;

    implementation



    {$R *.dfm}



    procedure TForm1.Button1Click(Sender: TObject);

    var

    MemoryStream: TMemoryStream;

    begin

    MemoryStream := TMemoryStream.Create;

    richedit_Editor.Lines.SaveToStream(MemoryStream);



    DataSource1.DataSet.Insert;

    Query1EDATE.AsString := '20010630';

    Query1FNAME.AsString := 'c:tempone.txt';

    Query1FILES.LoadFromStream(MemoryStream);



    MemoryStream.Free;



    with Query1 do begin

    Database1.StartTransaction;

    try

    ApplyUpdates;

    Database1.Commit;

    except

    Database1.Rollback;

    raise;

    end;

    CommitUpdates;

    end;

    end;



    end.











    난..안돼 wrote:

    > 답변에 감사합니다.

    >

    > 그런데 저는 파일로 저장하는 것이 아니라

    > RichEdit의 내용을 DB Table에 넣고 싶거든요.

    >

    > 이건 어떻게 해야되죠? 팁이라든가 Q&A 다 뒤져

    > 봤는데 찾을 수가 없었어요....

    >

    > 부탁 할께요.... 고수님....

    >

    >

    >

    >

    > 김일영 wrote:

    > > 델파이 팁모아에서 'File'로 검색했습니다.

    > > 아마 이것이면 충분할 것 같군요.

    > >

    > > http://www.delphi.co.kr/cgi-bin/cwb/CrazyWWWBoard.cgi?mode=read&num=1162&db=tips&fval=File&backdepth=1

    > >

    > > 검색을 생활화합시다.

    > >

    > >

    > >

    > > 난..안돼 wrote:

    > > > 여기에 있는 무수한 글을 읽어보며 정답을 찾기 위해 노력했지만

    > > > 저와 같은 고민을 하고 있는 분들의

    > > > 질문은 있으나 답이 없어 죄송스럽지만 글을 올립니다.

    > > > 상당히 간단한 문제이니 한번만 봐 주시길 바랍니다.

    > > >

    > > > Richedit에서 작성된 문서를 Oracle DB에 저장할려고 했는데....

    > > >

    > > > 1. 첫번째 시도

    > > > DataModule_Report.Query_ReportContents.ParamByName('contents').AsString :=

    > > > richedit_Editor.Lines.Text;

    > > >

    > > > 이렇게 한 후 updatesql을 이용해 DB에 저장을 하니 서식은 온데 간데없고

    > > > 순수 text만 저장이 되더군요.

    > > >

    > > > 2. 두번째 시도

    > > > 그래서 여기 있는 글들을 읽어보고 다음과 같이 하였으나 여전히 에러가

    > > > 생기며 안되네요.(이 방법이 맞는지 모르지만 시도 해봤습니다)

    > > >

    > > > var

    > > > ContentsStream : TMemoryStream;

    > > > begin

    > > > ContentsStream := TMemoryStream.Create;

    > > > richedit_Editor.Lines.SaveToStream(ContentsStream);

    > > >

    > > > DataModule_Report.Query_ReportContents.Close;

    > > > DataModule_Report.Query_ReportContents.SQL.Clear;

    > > > DataModule_Report.Query_ReportContents.SQL.Add('update report');

    > > > DataModule_Report.Query_ReportContents.SQL.ADD('set contents=:contents');

    > > > DataModule_Report.Query_ReportContents.SQL.ADD('where obj_id = :obj_id');

    > > > DataModule_Report.Query_ReportContents.ParamByName('contents').LoadFromStream

    > > > := (ContentsStream, ftBlob);

    > > > DataModule_Report.Query_ReportContents.ParamByName('obj_id').AsString

    > > > := '1234';

    > > > DataModule_Report.Query_ReportContents.ExecSQL;

    > > >

    > > > 도대체 어떻게 해야 서식을 포함한 모든 내용을 db에 저장 할 수

    > > > 있을 까요?

    > > >

    > > > 고수님 도와주세요.......

    > > >

    > > >