ahmed hakeem
asked on
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:=titl e;
//'File : '+openDialog.FileName;
// else ShowMessage('Open file was cancelled');
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:=titl
//'File : '+openDialog.FileName;
// else ShowMessage('Open file was cancelled');
ASKER
thank you,
but I used Varbinary(max) in sql
so I solved it as follow:
fStream:=TFileStream.Creat e(OpenDial og.FileNam e,fmOpenRe ad);
db.Edit;
dbAttachment.LoadFromStrea m(fStream) ;
Attachment_Title_Label.Cap tion:=Extr actFileNam e(OpenDial og.FileNam e);
fStream.Free;
but I used Varbinary(max) in sql
so I solved it as follow:
fStream:=TFileStream.Creat
db.Edit;
dbAttachment.LoadFromStrea
Attachment_Title_Label.Cap
fStream.Free;
if you solve it ... can you close the question?
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
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