none
URGENT PLEASE: Load Images from Database (Byte) into Image control RRS feed

  • Question

  • Hi, I have been looking for 2 days now I cannot find a solution to my problem.

    I am saving images directly to a MS SQL Server 2005 database as Byte Data using telerik upload control but I am not able to display them in my report. (report mode: local)

    I am using an Image Control like this:

    img2.value=First(Fields!Signature.Value)

    MIMMEType=image/jpeg

    Source=Database

     

    I have tried all the solutions I have found online but none has worked!!

    All i can see is the empty box with the red cross inside. I tried creating an aspx page that renders the image but i have not been successful in displaying the page into the image control: img.value="~/Pages/User/Images.aspx?=ID" & Fields!Signature.Value

     

    It works for my datagrid but not for the report.

     

    This is the last part of my project and i am stuck!!

     

    I will really appreciate any suggestion or guidence in this matter. Books? links? code?

    Thank you very much.

    amlibertad

    Tuesday, August 21, 2007 8:55 PM

All replies

  • Have you set EnableExternalImages to true on the report?

    Wednesday, August 22, 2007 4:17 PM
  • Thank you eldelo for you reply. Yes I have set the allow external images to true in the report. I cannot figure out what I am doing wrong or missing. The images are saved as byte and i can display them within a datagrid control but not with the image control of the report designer.  more ideas?

     

    angiedolfin

    Wednesday, August 22, 2007 9:31 PM
  • Sorry, I've been away from the forum for a while. If you run your code under the debugger, do you see any output in the debug output window? The rv generates some diagnostics into the dbg output window under debug... Also, does the rv display anything at all in the image controls on the report (such as a broken image icon)?

     

    Friday, August 24, 2007 11:00 PM
  • I have your solution... I did this for some barcodes and it drove me nuts too.

     

    In Image control properties do the following:

     

    In the MIMEType you have to put in the correct one depending on your image format you save into sql

    example:  image/png  or image/gif or image/jpeg

     

    http://www.w3schools.com/media/media_mimeref.asp

     

    In the Source property choose DataBase

     

    In Value drag and drop the byte() field from your dataset containing the image.

     

    Then ask your boss for a raise and go

     

    If anyone from the Reporting Services team is out there... you should really try to add those mime types into that MIMEType Property combobox. It will at least give them a hint on a first look.

    Monday, August 27, 2007 9:23 PM
  • Thank you Kanaida for your suggestion but i did what you indicate and still not working. This is really taking a toll on me.

     

    These are my settings:

    img2.value=First(Fields!OfferingInstitutionLogo.Value)

    img2.source=Database

    img2.MIMEType=image/jpeg

     

    In my database i have this field:

    OfferingInstitutionLogo - Image

     

    And this is what i use to upload the image to the db:

    Dim Logo As RadUpload = userControl.FindControl("LogoRadUpload")

    Dim LogoFile As UploadedFile = Nothing

    If Logo.UploadedFiles.Count > 0 Then

    LogoFile = Logo.UploadedFiles(0)

    End If

    Dim LogoData(LogoFile.InputStream.Length) As Byte

    LogoFile.InputStream.Read(LogoData, 0, LogoFile.InputStream.Length)

    AddImage(LogoData)

     

    And the result within the reportviewer using your suggestion is a broken image icon.

     

    Thanks.

     

     


    Tuesday, August 28, 2007 12:17 AM
  • Things to double check:

     

    Can you verify that the format is in fact jpeg thats being uploaded into the database?

     

    If you're using the ReportViewer control before you render the report make sure that the properties are set

    .LocalReport.EnableExternalImages = True

    .LocalReport.EnableHyperlinks = True 'If you plan to use them

     

    I would also as a test drag and drop that column from the dataset into the details cell of a new table just to see if the data is correct. Since it's actually an array of byte it may need to be handled differently.

    eg. maybe parsed via a custom vb function in the report. You can call them like this in the value expression...   =Code.FunctionName(Parameters)

     

    as a last resort you can do something alot simpler. since it's probably never worked. Just store the jpegs with unique names on a web server in a virtual directory and store the image name in a charcter field and in another table keep the path to web servers like so: (2 splitting server from images makes it easy to load balance later if needed)

     

    [ImagesTable]

    ImageID             ServerID 

    something.JPG        1

     

    [ServersTable]

    ServerID   ServerURL

    1               http://www.server.com/directory/

     

    then in the value field simply use an expression like : =Fields!ServerURL & Fields!ImageID

    Source Propery would need to be "External"

     

    This approach is what i like to personally use because it's easy to manage, move around and if your sql server is having issues it's easy to rebuild the tables just by using the DIR /B Command in the dos prompt to get a nice list of the filenames again.

     

    Also I just noticed SQL 2005 has an actual "Image" type. you may be able to try that. Not sure if thats what you're using.

     

    Tuesday, August 28, 2007 5:20 PM