how to Save Files to data base

after open file dialog how could i save this file to DB

openDialog := TOpenDialog.Create(self);
  openDialog.InitialDir := 'D:\';
 openDialog.Options := [ofFileMustExist];
//
//  // Allow only .dpr and .pas files to be selected
 openDialog.Filter :=
   'All files (*.*)|*.*';
//  // Display the open file dialog
 if openDialog.Execute  then
 title:=openDialog.FileName;
  TFileStream.Create (title, fmOpenRead);
  dbAttach_Title.Value:=title;
  //'File : '+openDialog.FileName;
//  else ShowMessage('Open file was cancelled');
ahmed hakeemAsked:
Who is Participating?
 
Geert GOracle dbaCommented:
1: depends on the database type
2: you want to save the contents ...

use a blobstream
https://edn.embarcadero.com/article/27462

another sample:
http://www.scalabium.com/faq/dct0141.htm
1
 
ahmed hakeemAuthor Commented:
thank you,
but I used Varbinary(max) in sql
so I solved it as follow:
 fStream:=TFileStream.Create(OpenDialog.FileName,fmOpenRead);
    db.Edit;
     dbAttachment.LoadFromStream(fStream);
     Attachment_Title_Label.Caption:=ExtractFileName(OpenDialog.FileName);
       fStream.Free;
0
 
Sinisa VukCommented:
if you solve it ... can you close the question?
0
All Courses

From novice to tech pro — start learning today.