images in dataset

rlangi05

Member
Joined
Jan 2, 2006
Messages
21
Programming Experience
1-3
Hi, I could use some help regarding putting images in a dataset.

I'm developing a windows application that accesses an sql server database in another server, an sql server 2000 database. A table, tblProducts, contains a field called ProdImage with type VarChar. ProdImage contains the path of the image which is stored in the server's file system.

I need to be able to load the records of tblProducts into a dataset including the image and not just the path since I want to use the images in a report.

What is the best way to do this? Does anybody have samples I can look at? Would doing this be better in SQL server 2005?

Thanks
 
Images

You know the path to the image, as this is stored in the DB. Would it not be easier to fetch the image off the disk as required for the report, or is that not possible for some reason?
 
There is a way to convert the image to a byte array to store in a dataset. CodeProject has a sample app, converting the image, storing it in a dataset, and then displaying in a Crystal Report File.

I'd for one would like to find an easier way to store an image in a dataset and display on a form but this is as much as I have found so far.

Dataset Image in Crystal Reports
 
Thanks for the reply guys, I appreciate it.
Tom, I found the exact same example you posted in the link but I cant get the image to display. I created a dataset with a field as System.Byte as the datatype and dragged the field into the Crystal report but the control that was created in the crystal report is different than that in the example. When I ran my project, there were no errors and all other data were displayed, only the image field was not showing anything.

I'm using visual studio 2005, is there anything else I should have done?
 
Thanks for the reply guys, I appreciate it.
Tom, I found the exact same example you posted in the link but I cant get the image to display. I created a dataset with a field as System.Byte as the datatype and dragged the field into the Crystal report but the control that was created in the crystal report is different than that in the example. When I ran my project, there were no errors and all other data were displayed, only the image field was not showing anything.

I'm using visual studio 2005, is there anything else I should have done?

Hello:

I downloaded the example, it worked fine in VS2005 & VS2008 for me. Below are several thoughts I have to consider and check.

01)

Did his example work for you or was it just your recreation of it that is not working?

02)

Also is your computer formatted for 32 or 64 bit? The example is coverting it to 32 bit's. (br.ReadBytes(Convert.ToInt32((fs.Length)))

03)

Is the problem only in crystal or in the dataset itself? After storing the image to the dataset, try reconverting it to display from the dataset into a picturebox.

04)

What type of field was drawn onto your crystal report? I can see in his example that he is using a Blob Field object, you mention it created something different for your report.

Are you using crystal in the VS software or do you have a full version of CR installed; if so what version?

05)

What type of image file are you trying? I have tried the following (jpg, jpeg, png, gif, bmp, & ico); the only two out of them that would not display in the crystal report were the gif & ico file(s).
 
Thanks for the help. I finally got it working.
It was my mistake. At first when I created the dataset object, the image column I set to System.Byte datatype which was wrong. Later on I changed it to System.Byte() but I forgot to drag it to the report document after verifying the database.

Anyway, thanks for the help guys
 
Back
Top