display images without having them on the disk?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Yoramo

    display images without having them on the disk?

    Hello

    is it possible to display images on a ASPX without having them on the disk
    of the server ?

    I have images in a DB and whould like to display them on a web page. writing
    them to disk seems very costly.

    is it posible to create them in memory and some how give them to the client
    to display?

    thanks in advance
    Yoramo.


  • white sheng

    #2
    Re: display images without having them on the disk?

    hi,you can do it just like the following example.

    private void Page_Load(objec t sender, System.EventArg s e)
    {
    SqlConnection mycon = new SqlConnection(" your connection string");
    mycon.Open();

    int liid = int.Parse(Reque st.QueryString["id"]);
    string sqlText = "SELECT img_name, img_data, img_contenttype FROM image1
    where id="+liid;
    SqlCommand MyCommand = new SqlCommand (sqlText, mycon);
    SqlDataReader dr =MyCommand.Exec uteReader();
    if(dr.Read())
    {
    Response.Conten tType = (dr["img_contenttyp e"].ToString());
    Response.Binary Write((byte[])dr["img_data"]);
    }
    mycon.Close();
    }


    Comment

    • Yoramo

      #3
      Re: display images without having them on the disk?

      hello

      Thanks for your replay.
      can you show me how whould the aspx file look like for such a code to
      work?

      Yoramo.


      "white sheng" <whitesheng@unt soft.com.cn> wrote in message
      news:ec0hGnq%23 DHA.340@tk2msft ngp13.phx.gbl.. .[color=blue]
      > hi,you can do it just like the following example.
      >
      > private void Page_Load(objec t sender, System.EventArg s e)
      > {
      > SqlConnection mycon = new SqlConnection(" your connection string");
      > mycon.Open();
      >
      > int liid = int.Parse(Reque st.QueryString["id"]);
      > string sqlText = "SELECT img_name, img_data, img_contenttype FROM[/color]
      image1[color=blue]
      > where id="+liid;
      > SqlCommand MyCommand = new SqlCommand (sqlText, mycon);
      > SqlDataReader dr =MyCommand.Exec uteReader();
      > if(dr.Read())
      > {
      > Response.Conten tType = (dr["img_contenttyp e"].ToString());
      > Response.Binary Write((byte[])dr["img_data"]);
      > }
      > mycon.Close();
      > }
      >
      >[/color]


      Comment

      • Kevin Spencer

        #4
        Re: display images without having them on the disk?

        He already did. There is no Template HTML. It simply sends an image. You
        include a reference to that page as the URL for an image tag in another
        page.

        --
        HTH,
        Kevin Spencer
        ..Net Developer
        Microsoft MVP
        Big things are made up
        of lots of little things.

        "Yoramo" <yoramo@[NOSPAM]hotmail.com> wrote in message
        news:#8fDPEx#DH A.2524@TK2MSFTN GP10.phx.gbl...[color=blue]
        > hello
        >
        > Thanks for your replay.
        > can you show me how whould the aspx file look like for such a code to
        > work?
        >
        > Yoramo.
        >
        >
        > "white sheng" <whitesheng@unt soft.com.cn> wrote in message
        > news:ec0hGnq%23 DHA.340@tk2msft ngp13.phx.gbl.. .[color=green]
        > > hi,you can do it just like the following example.
        > >
        > > private void Page_Load(objec t sender, System.EventArg s e)
        > > {
        > > SqlConnection mycon = new SqlConnection(" your connection string");
        > > mycon.Open();
        > >
        > > int liid = int.Parse(Reque st.QueryString["id"]);
        > > string sqlText = "SELECT img_name, img_data, img_contenttype FROM[/color]
        > image1[color=green]
        > > where id="+liid;
        > > SqlCommand MyCommand = new SqlCommand (sqlText, mycon);
        > > SqlDataReader dr =MyCommand.Exec uteReader();
        > > if(dr.Read())
        > > {
        > > Response.Conten tType = (dr["img_contenttyp e"].ToString());
        > > Response.Binary Write((byte[])dr["img_data"]);
        > > }
        > > mycon.Close();
        > > }
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • Yoramo

          #5
          Re: display images without having them on the disk?

          Hello Kevin

          How does it know to place the image in a specific IMG tag or a Image button?

          yoramo

          "Kevin Spencer" <kevin@takempis .com> wrote in message
          news:u2vIMv7%23 DHA.2072@TK2MSF TNGP11.phx.gbl. ..[color=blue]
          > He already did. There is no Template HTML. It simply sends an image. You
          > include a reference to that page as the URL for an image tag in another
          > page.
          >
          > --
          > HTH,
          > Kevin Spencer
          > .Net Developer
          > Microsoft MVP
          > Big things are made up
          > of lots of little things.
          >
          > "Yoramo" <yoramo@[NOSPAM]hotmail.com> wrote in message
          > news:#8fDPEx#DH A.2524@TK2MSFTN GP10.phx.gbl...[color=green]
          > > hello
          > >
          > > Thanks for your replay.
          > > can you show me how whould the aspx file look like for such a code[/color][/color]
          to[color=blue][color=green]
          > > work?
          > >
          > > Yoramo.
          > >
          > >
          > > "white sheng" <whitesheng@unt soft.com.cn> wrote in message
          > > news:ec0hGnq%23 DHA.340@tk2msft ngp13.phx.gbl.. .[color=darkred]
          > > > hi,you can do it just like the following example.
          > > >
          > > > private void Page_Load(objec t sender, System.EventArg s e)
          > > > {
          > > > SqlConnection mycon = new SqlConnection(" your connection string");
          > > > mycon.Open();
          > > >
          > > > int liid = int.Parse(Reque st.QueryString["id"]);
          > > > string sqlText = "SELECT img_name, img_data, img_contenttype FROM[/color]
          > > image1[color=darkred]
          > > > where id="+liid;
          > > > SqlCommand MyCommand = new SqlCommand (sqlText, mycon);
          > > > SqlDataReader dr =MyCommand.Exec uteReader();
          > > > if(dr.Read())
          > > > {
          > > > Response.Conten tType = (dr["img_contenttyp e"].ToString());
          > > > Response.Binary Write((byte[])dr["img_data"]);
          > > > }
          > > > mycon.Close();
          > > > }
          > > >
          > > >[/color]
          > >
          > >[/color]
          >
          >[/color]


          Comment

          • Kevin Spencer

            #6
            Re: display images without having them on the disk?

            <img src="ImageMaker .aspx">

            --
            HTH,
            Kevin Spencer
            ..Net Developer
            Microsoft MVP
            Big things are made up
            of lots of little things.

            "Yoramo" <yoramo@[NOSPAM]hotmail.com> wrote in message
            news:etKOln9#DH A.1732@TK2MSFTN GP12.phx.gbl...[color=blue]
            > Hello Kevin
            >
            > How does it know to place the image in a specific IMG tag or a Image[/color]
            button?[color=blue]
            >
            > yoramo
            >
            > "Kevin Spencer" <kevin@takempis .com> wrote in message
            > news:u2vIMv7%23 DHA.2072@TK2MSF TNGP11.phx.gbl. ..[color=green]
            > > He already did. There is no Template HTML. It simply sends an image. You
            > > include a reference to that page as the URL for an image tag in another
            > > page.
            > >
            > > --
            > > HTH,
            > > Kevin Spencer
            > > .Net Developer
            > > Microsoft MVP
            > > Big things are made up
            > > of lots of little things.
            > >
            > > "Yoramo" <yoramo@[NOSPAM]hotmail.com> wrote in message
            > > news:#8fDPEx#DH A.2524@TK2MSFTN GP10.phx.gbl...[color=darkred]
            > > > hello
            > > >
            > > > Thanks for your replay.
            > > > can you show me how whould the aspx file look like for such a code[/color][/color]
            > to[color=green][color=darkred]
            > > > work?
            > > >
            > > > Yoramo.
            > > >
            > > >
            > > > "white sheng" <whitesheng@unt soft.com.cn> wrote in message
            > > > news:ec0hGnq%23 DHA.340@tk2msft ngp13.phx.gbl.. .
            > > > > hi,you can do it just like the following example.
            > > > >
            > > > > private void Page_Load(objec t sender, System.EventArg s e)
            > > > > {
            > > > > SqlConnection mycon = new SqlConnection(" your connection[/color][/color][/color]
            string");[color=blue][color=green][color=darkred]
            > > > > mycon.Open();
            > > > >
            > > > > int liid = int.Parse(Reque st.QueryString["id"]);
            > > > > string sqlText = "SELECT img_name, img_data, img_contenttype[/color][/color][/color]
            FROM[color=blue][color=green][color=darkred]
            > > > image1
            > > > > where id="+liid;
            > > > > SqlCommand MyCommand = new SqlCommand (sqlText, mycon);
            > > > > SqlDataReader dr =MyCommand.Exec uteReader();
            > > > > if(dr.Read())
            > > > > {
            > > > > Response.Conten tType = (dr["img_contenttyp e"].ToString());
            > > > > Response.Binary Write((byte[])dr["img_data"]);
            > > > > }
            > > > > mycon.Close();
            > > > > }
            > > > >
            > > > >
            > > >
            > > >[/color]
            > >
            > >[/color]
            >
            >[/color]


            Comment

            Working...