locked
how to display images at runtime in a web appplication RRS feed

  • Question

  • User1441157511 posted

    i use C#. and also, how do i get an image to be downloaded from mysql database at runtime upon request. here is a bit of my declaration code and conditional construct code

     byte [] f = (byte[])(read["Passport"]); // this reads d byte data from the column passport in the database and assigns it to byte f.

    if (f == null)

     {
           admin1pass.ImageUrl = null;
     }
     else
     {
           MemoryStream ms = new MemoryStream(f); // this holds the image gotten from the database
           admin1pass.ImageUrl = System.Drawing.Image.FromStream(ms);
     }

    'now thats where i'm stuck. i hv used the

    using System.Drawing;
    using System.Data;

    namespaces but none contains the class Image which is oftren what i use in windows form apps.

    Saturday, August 2, 2014 7:12 PM

Answers

  • User2103319870 posted

    EasyHero

    namespaces but none contains the class Image

    Image class is a part of System.Drawing Namespace. Have you added the reference of Drawing dll in your project.

    Please follow the below steps to refer the assembly in your project

    • Open your Project within the Solution Explorer
    • Right-click the References folder and Choose Add Reference
    • Find and select the System.Drawing assembly from the list provided , if you cannot find the dll , use the Browse button and go to the location where dll resides.
    • Click Ok button to add it to your Project.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, August 2, 2014 7:51 PM
  • User-1716253493 posted

    http://www.developerfusion.com/code/5223/using-ashx-files-to-retrieve-db-images/

    admin1pass.ImageUrl = "getimage.ashx?id=1000";

    create getimage.ashx to get image from db, then you can pass id query string to get spesific image

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, August 2, 2014 11:44 PM

All replies

  • User2103319870 posted

    EasyHero

    namespaces but none contains the class Image

    Image class is a part of System.Drawing Namespace. Have you added the reference of Drawing dll in your project.

    Please follow the below steps to refer the assembly in your project

    • Open your Project within the Solution Explorer
    • Right-click the References folder and Choose Add Reference
    • Find and select the System.Drawing assembly from the list provided , if you cannot find the dll , use the Browse button and go to the location where dll resides.
    • Click Ok button to add it to your Project.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, August 2, 2014 7:51 PM
  • User-1716253493 posted

    http://www.developerfusion.com/code/5223/using-ashx-files-to-retrieve-db-images/

    admin1pass.ImageUrl = "getimage.ashx?id=1000";

    create getimage.ashx to get image from db, then you can pass id query string to get spesific image

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, August 2, 2014 11:44 PM