Image Widget- Type Database

Image Widget- Type Database


I m trying to read the image from Database and show in Image Widget but i getting Error[Reference not set to instance of an object].
1.i have 2 table Userdetails and ImageDocument. we have foreign key reference to Userdetails.Id=ImageDocument.Id.During the Preparation Using SQL i retrived two tables without any condition.Then for Image Widget i set Property
Atrribute -Imagedocument.Image
Entity Identifier-GetDoc.List.current.Userdetails.Id [In preparation GetDoc Query is used]
Filename - GetDoc.List.Current.ImageDocument.Filename

Can u please tell what i did wrong here?
Hi Devaraj,

In theory, the code you have there should be working.

However, it is not a good idea to create relationships with Userdetails.Id=ImageDocument.Id , since they are both autonumbers and unique, which means that you do not have control for their creation. If everything goes well, it'll be fine, but should an error occur, then everything goes downhill.

I would suggest either having
an extra attribute: either Userdetails.Id=ImageDocument.UserId or Userdetails.ImageId=ImageDocument.Id .

Asides from that, trying to debug your situation, have you tried executing a query to the database with the UserId that's giving problems, and seeing if an image actually exists there, with the right Id? Does it work?

And regarding the
GetDoc.List.current.Userdetails.Id, where are you using this? In a TableRecords, or somewhere else? The idea would always be to use the Widget's List/Record's UserId.

I hope this helps. Let us know how it goes.


Paulo Tavares
Thanks for your Reply

I understand some what from your Reply.
Did you saw my attachment.
I assigned GetDoc.List.current.Userdetails.Id to the Image Widget Property.
Entity Identifier-GetDoc.List.current.Userdetails.Id
1.Can you please send some sample oml for these process.
2.If i stored the Pdf in DB.Its not possible to show in Image Widget.In this case In What Control we should show?

Hi Devaraj,

I've attached a small sample on how to display images from the database. I hope this helps.

Indeed, it only works for images, as expected, and not for PDFs. If you want to display a PDF in a webpage, you should have a web page where in the preparation it will GET the PDF file from the database, and then end with a Download node, with "Save to Disk" set to false, using the content you got from the database.

After that, you should look into how to embed a PDF in a web page, using the URL from that specific web page. You can look into this thread, using HTML, or also to this thread in our forums. I hope it gives you a pointer in terms of which directions to pursue.


Paulo Tavares