Board index » delphi » How to put a word file in sql db

How to put a word file in sql db

Dear all,
         We would like to put a binary file as MS Word in SQL database.
         How to do this? Please guide me or a little sample.
Thank for all,
Sukho Somtrakoul
 

Re:How to put a word file in sql db


Sukho,
     Although this isn't using OleAutomation, try the following..  You will
need a form with a database and a table that are connected as well as 2
buttons.  Edit the following code to fit your table.  The TBlobField makes
this really easy to do.

procedure TForm1.Button1Click(Sender: TObject);
var
  BF : TBlobField ;
begin
  BF := TBlobField.Create(self) ;
  try
    Table1.Insert ;
    Table1.FieldByName('filename').asString := 'test.txt' ;
    BF:= Table1.FieldByName('FileContent') as TBlobField;
    BF.LoadFromFile('c:\\filetest\\test.txt') ;
    Table1.Post ;
  except
    showmessage('error posting') ;
  end;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  BF : TBlobField ;
begin
  Table1.First ;
  BF := TBlobField.Create(self) ;
  BF:= Table1.FieldByName('FileContent') as TBlobField;
  BF.SaveToFile('c:\\filetest\\testout.txt') ;
end;

--
-------------------------------
Paul Qualls

try my "Outlook Program/Custom Form Launcher"
http://paul.qualls.com/FormLaunch.html

Freeware Outlook Add-in to Launch programs and Outlook Forms
from a custom button on Outlook's main toolbar
-------------------------------

Quote
"Sukho" <Suk...@email.com> wrote in message

news:886dqk$gk87@bornews.borland.com...
Quote
> Dear all,
>          We would like to put a binary file as MS Word in SQL database.
>          How to do this? Please guide me or a little sample.
> Thank for all,
> Sukho Somtrakoul

Other Threads