If you want to store images in your postgreSQL database and display them directly in a WinDev image control, Then you need to configure your database to return the bytea format as ‘Escape’ instead of Hex. With V9 of PostgreSQL the default changed to Hex and apparently pcSoft has not caught up with the new default format. Here’s the command you need to execute on your database:
ALTER DATABASE databasename SET bytea_output TO 'escape';
Now, back to your regular schedule program….
A few have asked for the rest of the code to get an image back and forth between the database and WX. So here is a quick overview of the process, this example is if you have a form where you want the user to be able to select the image that gets stored. Once you have it in the database, just linking an image control to the variable and doing a filestoscreen will display it..
1. You must make the change to your database as outlined above.
2. In PostgreSQL the image filed is defined as a bytea:
CREATE TABLE developer ( devsysid serial NOT NULL, logo bytea, CONSTRAINT "Pk_Developer" PRIMARY KEY (devsysid) )
3. In your Analysis it is defined as a Sound,image, binary field
4. Place an image control on your screen (ImgLogo is what I am calling it in this example) and link it to the bytea field (logo) in you analysis
5. So the user can lookup the image file, and store it in the database field, add a file lookup control to your screen with the code for it
IF fFileExist(LogoFile) THEN ImgLogo = LogoFile END
Now the normal Hadd, Hmodify will update the database. And screentofile, filetoscreen will make the logo display in the image control
One thought on “PostgreSQL Images with WinDev – Update 12/21/2012”
Thanksfuly you’re so great to share this tips.
this solve my problem…