1. Winthor Caingles
  2. PowerBuilder
  3. Friday, 1 April 2022 01:16 AM UTC

Good day,

I have not used saving PDF to database using MSSQL... any advice or script that will solve my problem?

thank you for you help...

 

 

 

Miguel Leeuwe Accepted Answer Pending Moderation
  1. Friday, 1 April 2022 12:26 PM UTC
  2. PowerBuilder
  3. # 1
  • What's the type of the "files" field in your "dat_pdf" table?
  • What error text can you see in sqlca when the update fails?
Comment
There are no comments made yet.
Sivaprakash BKR Accepted Answer Pending Moderation
  1. Friday, 1 April 2022 12:10 PM UTC
  2. PowerBuilder
  3. # 2

Hello,

Here is a sample program to upload pdf file and save it to a SQL Server database.  I've attached PB 2019 R3 project (in zip file) with structure.sql file to create the table.  

Modify the database credentials at application open event.

HTH

Happiness Always
BKR Sivaprakash

 

Attachments (1)
Comment
There are no comments made yet.
Winthor Caingles Accepted Answer Pending Moderation
  1. Friday, 1 April 2022 01:59 AM UTC
  2. PowerBuilder
  3. # 3

this is the script that I am working on...but it is not working...no data saved to the database

 

 

long ll_file, ll_bytes, ll_pdf_key = 1
blob lblob_file


ll_file = FileOpen("C:\AFFC\otia.pdf", StreamMode!)
ll_bytes = FileReadEx(ll_file, lblob_file) /* ll_bytes value is 7982565*/
FileClose(ll_file)
if ll_bytes > 0 then


Updateblob dat_pdf
set files = :lblob_file
where dedcode = '1H1'
commit SQLCA;


end if

Comment
  1. Philippe PILAT
  2. Friday, 1 April 2022 10:01 AM UTC
if I remember correctly,autocommit must be set to TRUE before UPDATEBLOB.



HTH.



Best Regards,
  1. Helpful
  1. Miguel Leeuwe
  2. Friday, 1 April 2022 12:25 PM UTC
Hi Philippe,

I think you're right for MS SqlServer, but not for all Databases like Oracle.
  1. Helpful
  1. Ronnie Po
  2. Friday, 1 April 2022 17:18 PM UTC
Have you confirmed that the row exists in dat_pdf before you execute the UPDATEBLOB command?
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Friday, 1 April 2022 01:55 AM UTC
  2. PowerBuilder
  3. # 4

Hi Winthor;

   The key here are the PB commands UpdateBlob() & SelectBlob(). The SS column type would be "Image".

Regards ... Chris

Comment
  1. Winthor Caingles
  2. Friday, 1 April 2022 02:05 AM UTC
this is the script that I am working on...but it is not working...no data saved to the database











long ll_file, ll_bytes, ll_pdf_key = 1

blob lblob_file





ll_file = FileOpen("C:\AFFC\otia.pdf", StreamMode!)

ll_bytes = FileReadEx(ll_file, lblob_file) /* ll_bytes value is 7982565*/

FileClose(ll_file)

if ll_bytes > 0 then





Updateblob dat_pdf

set files = :lblob_file

where dedcode = '1H1'

commit SQLCA;





end if
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.