Home > Back-end >  Delphi deposited the PDF files in the SQL database
Delphi deposited the PDF files in the SQL database

Time:09-19

Everybody is good my Delphi is using a SQL database, need through the Delphi PDF files in the SQL database, and then read
When the new deposited the corresponding files in 123 (PDF file) in a SQL database
Query is a query to 123 also show its corresponding PDF files
I need to do? O great god teach

Score is not much, a great god glad

CodePudding user response:

For PDF files, after more than 1 m, the data read speed is slow, and take up the space is big, cause the database to read slowly,
Recommend not stored away in the database, but is stored in the disk directory, database only save "directory file name,"

If you have to be deposited in the database, in the form of binary files to the database, if is three floors, the file is transfer to flow or character form transmission and preservation,
The code is roughly:
1, establish a Blob field in a database table 'FBD', is used to save the PDF file,
2, the code
ADOQuery1. Edit;
TBlobField (ADOQuery1 FieldByName (' PDF ')). The LoadFromFile
ADOQuery1. Post;

Three layers of code is more complex,

CodePudding user response:

Code can you be more specific point   novice, not very understand

CodePudding user response:

reference 1st floor lyhoo163 response:
for PDF files, after more than 1 m, the data read speed is slow, and take up the space is big, cause the database to read slowly,
Recommend not stored away in the database, but is stored in the disk directory, database only save "directory file name,"

If you have to be deposited in the database, in the form of binary files to the database, if is three floors, the file is transfer to flow or character form transmission and preservation,
The code is roughly:
1, establish a Blob field in a database table 'FBD', is used to save the PDF file,
2, the code
ADOQuery1. Edit;
TBlobField (ADOQuery1 FieldByName (' PDF ')). The LoadFromFile
ADOQuery1. Post;

Three layers of code is more complex,
code can you be more specific??????? A novice, not particularly understand

CodePudding user response:

Can baidu once, estimate a lot, or stored in local disk, save in the database file path.

CodePudding user response:

The original poster to solve, I also need to, please share

CodePudding user response:

To obtain PDF file content, or the use quickpdf or foxit DLL

CodePudding user response:

Procedure Tmainform. Button1Click (Sender: TObject);
//var
//the Stream: TMemoryStream;
The begin
If ((dm) DcmtkADOQReport) Active=false) or (dm) DcmtkADOQReport) RecordCount=0)) then the exit;
Dm. Adoquery1. Close;
Dm. Adoquery1. SQL. Text:='select * from RptBin where Report_ID_parent=' + dm. DcmtkADOQReport. Fieldbyname (' Report_ID). AsString;
Dm. Adoquery1. Open;
If dm. ADOQuery1. RecordCount<> 0 then
The begin
TBlobfield (dm) adoquery1) fieldbyname (' Data ')). SaveToFile (' d: \ Ris \ '+ dm. DcmtkAdoQreport. Fieldbyname (' Report_ID). AsString +' PDF ');
ShellExecute (handle, the 'open', pansichar (' d: \ Ris \ '+ dm. DcmtkAdoQreport. Fieldbyname (' Report_ID). AsString +' PDF '), nil, nil, SW_SHOW);
end;
end;

Procedure Tmainform. Button2Click (Sender: TObject);
//var
//the Stream: TMemoryStream;
The begin
//the Stream:=TMemoryStream. Create;//create a memory stream
Dm. DcmtkADOQReport. Close;
Dm. DcmtkADOQReport. SQL. Text:="Insert into RptBin (DataType, Data, Report_ID_parent) values (' + format (', '% s',' '[' PDF']) + ', '+' : PdfData '+', '+' 20170809002 '+') '.
Dm. DcmtkAdoQReport. The Parameters. ParamByName (' PdfData). LoadFromfile (' d: \ ab. PDF, ftVarBytes);//read
Dm. DcmtkADOQReport. ExecSQL;

end;

CodePudding user response:

If it is on SQL Server 2008 and Microsoft look carefully: https://www.microsoft.com/zh-cn/download/confirmation.aspx? Id=44272 for BLOB field is to install the driver on the client's
  • Related