cancel
Showing results for 
Search instead for 
Did you mean: 

Looking for a sample Read of tif file, and save to a sql server db.

Former Member
0 Kudos

I'm looking for an example, of reading a tif file, and saving this tif file to a sql server database.

I'd also like to display the image, to the user at the same time.

Is there any difference in the way the image is save from powerbuilder

as opposed to another application.  There will be a different program saving images to the database as well

thanks

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Scot;

If you are using PB 12.5.x or higher, you can use the new Table Blob feature in the DataWindow to view the images directly. For updating SS with the TIFF images, you just need to use the FileReadEx ( ) command and the UpdateBlob DML statement.

  I have have tons of example code to do this with either SS, SA or ASE. We use TIFF images and PB and/or /Appeon applications to do what you are asking about all the time here at Passport Canada.

Regards ... Chris

Former Member
0 Kudos

I haven't really used blobs before.  It looks like sql server would use varbinary as a blob.. (which is an image in sql server) .  When I try to select the image column, in the datawindow painter it tells me that the column requires the use of embedded sql statement.

can you point me in the right direction?   thanks

Former Member
0 Kudos

Hi Scot;

1) You can not select any blob column in your SQL select for a DW.

2) If you are not on PB 12.5.x or higher the Table Blob feature is not an option.

3) If you are on PB 12.5.x or higher ...

    - Build a DW object using non-blob columns

    - In the DW painter's detail band - add a TableBlob control

    - Then select the table's blob column the DWO is to use in the next dialogue

        => provide a DB Key mapping

        => Select a type of "image"

 

4) Now when you perform a Retrieve on the DW, this is what the user would see ...

HTH

Regards ... Chris

Former Member
0 Kudos

just an fyi.    I'm using 12.5.2 classic

Former Member
0 Kudos

I managed to get the datawindow to pull up with a JPG file that I imported.

Does it matter, what type of format that the image file is in?

I performed the following command, to get a sample image in place

INSERT INTO Employees (Id, Name, Photo)

SELECT 10, 'John', BulkColumn

FROM Openrowset( Bulk 'C:\castle.jpg', Single_Blob) as EmployeePicture

Are there things I need to do, in displaying a Tiff file instead of a jpg?

do I need to look into the Table Blob help more?

Former Member
0 Kudos

Excellent news!

We use the TB DW for jpeg, bmp, and tiff images at work.

Note1:  cannot handle multi-page (scene) Tiff's.

Note2: cannot handle jpeg2000 images

Former Member
0 Kudos

Is there any way, to be able to save multi-page tiff files?

is there a way, to save any type of image file... and display it, in a powerbuilder app?

Former Member
0 Kudos

Hi Scot;

  What I do is use ImageMagicK to disassemble the multi-page TIFF's into a separate image file for each scene (page). Then, save each page/scene's image in a SS / ASE blob (image) column marking the blob table entry as Page 1,2,3, etc.  

  No, PB can not handle these types of multi-page/scene TIFF files natively. Neither can a lot of software out there BTW.

HTH

Regards ... Chris

former_member190719
Active Contributor
0 Kudos


is there a way, to save any type of image file... and display it, in a powerbuilder app?

See my blog article here on SCN on using a .Net control to display TIFF files.

Former Member
0 Kudos

Would it be possible, to store the image in the database until you need to view it?

At the time, you need to view it... export it to a temporary file?

that way... I could technically store many different types of files on the database

We have a produce called global360 for viewing image files.

We do have a requirement, to have multi-page images. 

I'm kind of looking for an easy way to do this.  I think my choice would have been, to save

images to the file system as opposed to the database.

I saw a way of insert in the management studio, but not sure what the syntax

would be within powerbuilder... .or how the writing out of the file

INSERT INTO Employees (Id, Name, Photo)

SELECT 10, 'John', BulkColumn

FROM Openrowset( Bulk 'C:\castle.jpg', Single_Blob) as EmployeePicture

I'd appreciate any help or suggestions

former_member190719
Active Contributor
0 Kudos

Would it be possible, to store the image in the database until you need to view it?

At the time, you need to view it... export it to a temporary file?

Absolutely.  That's the way we've handled images stored in the database for years.  With non multi page format you can display the image and then immediately delete the image.  PowerBuilder only needs it for the initial display.  With a multiple page image though you'd need to keep the temporary image around until the user stops viewing it.  That's because the way a multi page image is displayed (at least in my sample) is to display one page of the image at a time and re-read the image file when you need another page.


I'm kind of looking for an easy way to do this.  I think my choice would have been, to save

images to the file system as opposed to the database.

That actually complicates things a bit.  The database is a good place to store images if you ever need to move the database and images.


I saw a way of insert in the management studio, but not sure what the syntax

would be within powerbuilder... .or how the writing out of the file

PowerBuilder handles blobs (e.g., image files) separately from the main insert.   You perform the insert for all of the columns except the image file, and then do a UpdateBlob statement to add the blob to the already inserted record.