Home > database >  Emergency pb from SQL server image field generated in the PDF file
Emergency pb from SQL server image field generated in the PDF file

Time:09-16

Recently in a project, in the image field of SQL server to store the PDF file, now want to take out to generate PDF files, but the file is created, but with the PDF open the file loss, I am so written, first wrote a read f_write function
//the return value: 1-0 - success of int

ULONG ll_len li_count, loops
Int li_FileNum
Blob lblb_b
Int liResult=1

Ll_len=len (ib_file)
IF ll_len & gt; THEN 32765
IF the Mod (ll_len, 32765)=0 THEN
Loops=ll_len/32765
The ELSE
Loops=(ll_len/32765) + 1
END the IF
The ELSE
Loops=1
END the IF


Li_FileNum=FileOpen (is_filename StreamMode! The write! , Shared! The Replace!
If li_FileNum=1 then
Messagebox (" prompt ", "unable to open file" + is_filename)
Return 0
End the if
FOR li_count=1 to loops
Lblb_b=blobmid (ib_file, (li_count - 1) * 32765 + 1, 32765)
If FileWrite (li_FileNum lblb_b)=1 then
Messagebox (" prompt ", "write the file" + is_filename + "failure")
LiResult=0
The exit
End if//8010
NEXT
Fileclose (li_FileNum)

//if liResult=1 then
//liResult=gf_setfiletime (is_filename idt_file_time)
//end if

Return liResult

Then, removed from a database using selectblob is as follows:
Blob lb_blob
String ls_filename
Int li_ret2

Debugbreak ()
Ls_filename='E: \ HFReport \ ReportFile, 10, 68. The PDF'

Selectblob F_ExtContent into: lb_blob from KM_LIS_ExtReport where F_RequestCode='0400422228'
And F_ReportBarCode='SH14333894438128 and F_IndexNo=1;
If the sqlca. Sqlcode<> 0 then
Messagebox (' system ', 'data read failure)
Return
End the if

Li_ret2=f_writefile (lb_blob ls_filename)
If li_ret2=1 Then
Messagebox (', 'success! ')
The Else
Messagebox (', 'failure! ', stopsign!)
End the if

File is successful, an error, but failed to open file has been damaged, estimate code where you have any questions, please inform me know friend, is very urgent, thank you
Related to the job, ask everybody to help, thank you

CodePudding user response:

You on the Internet to find somebody else mature code first, then, their first save a smaller PDF files inside, then out and save again, and see if I can open,

CodePudding user response:

You on the Internet to find somebody else mature code first, then, their first save a smaller PDF files inside, then out and save again, and see if I can open,

CodePudding user response:

You on the Internet to find somebody else mature code first, then, their first save a smaller PDF files inside, then out and save again, and see if I can open,

CodePudding user response:

Check the lb_blob and file size, whether to have read correctly
  • Related