Video Screencast Help
Symantec to Separate Into Two Focused, Industry-Leading Technology Companies. Learn more.

Display image from SQL Database in a webform

Created: 20 May 2013 • Updated: 21 May 2013 | 8 comments
This issue has been solved. See solution.

I am working on an employee information look-up workflow.  I have a SQL table with all of an employee's information including a picture.  I need help figuring out how to display that picture in a web form.  I have the picture as a variable.

Operating Systems:

Comments 8 CommentsJump to latest comment

reecardo's picture

Assuming you have the picture data as a byte array (Byte[]) on the stream, try the following:

1. Use Add New Data Element to put a FileDataType on the stream.

2. Map the picture data byte array into the FileDataType you added using a Single Value Mapping

3. Add an image to your form. Specify File as the source and then specify the FileDataType variable.

Unsure if this will work, but it's worth a try

SOLUTION
michael.george's picture

For sheer curiousity, I gave this a shot, but I wasn't able to get it functional. When I brought back the stream from the db table, it appeared that all was well, but it wouldn't display after mapping to a filedatatype. Oddly enough, if I wrote the file to the hard drive, the file was normal and opened just fine; it just refused to display in the web form.

I don't need this to work, but darn I'd like to see it work just for fun.

If a post solves your issue, please mark it as a solution. It makes these forums better for everyone.

John Atkins's picture

Thank both of you for the explainations and giving it a try.  I also gave it another try, but couldn't get it to display.

John Atkins
Advanced Client Services Engineer
LifeWay Christian Resources
http://www.lifeway.com

TN User Group Membership Director
 

John Atkins's picture

I did get it to work after all.  I was using the wrong File Data:.

 

Thanks a bunch!!!!

John Atkins
Advanced Client Services Engineer
LifeWay Christian Resources
http://www.lifeway.com

TN User Group Membership Director
 

michael.george's picture

Awesome! I still can't mine to load the image, so I have to ask, what's the gotcha that you missed the first time round? I'm guessing I'm missing it, too...

If a post solves your issue, please mark it as a solution. It makes these forums better for everyone.

John Atkins's picture

Mine will not show until I'm in debug first of all.  Second when I put the Data Type in for the image I choose the wrong one.  Once I did that everything worked just as y'all had described it.

John Atkins
Advanced Client Services Engineer
LifeWay Christian Resources
http://www.lifeway.com

TN User Group Membership Director
 

John Atkins's picture

Didn't really get all that to work.  Maybe I just did it wrong. Here is what I have the best way I can explain it. 

Sql table with user's information including first, last name, email address, badge#, BLOB of their picture and so on.  Form the first form you select to search by Badge#.  It takes that number throught a custom component that I wrote and brings back all other information attached to that Badge# including a variable called EmpPicture[First] which should be the picture and is what I am wanting to display.

John Atkins
Advanced Client Services Engineer
LifeWay Christian Resources
http://www.lifeway.com

TN User Group Membership Director
 

michael.george's picture

Just to expand on what reecardo was saying, I've attached some screen shots of what I think he was driving at. What you've done is great, so now you need to add a new data element of type "filedatatype" and a single value mapping component like this after your created sql component:

Screen Shot 2013-05-21 at 7.41.13 AM.png

 

Your single value mapping should look like so:

Screen Shot 2013-05-21 at 7.40.13 AM.png

 

Keep in mind that I probably put different column names there as I just whipped something together. Finally, on your form builder component, drop in an image component and configure like so:

Screen Shot 2013-05-21 at 7.42.57 AM.png

 

Make sense now? Of course, all this said, I couldn't get this to display the image (see comment above).

If a post solves your issue, please mark it as a solution. It makes these forums better for everyone.