writing images from SQL in a table...

Hi,

I would like to know if there is a way to print in a html page a table with 4 images, and it's description queryed from SQL Server...

Like, I have already a page, and in the body, I have <% response.write(table) %>

And in my .cs I insert all html....and together with this html I need to put the image !!!

Thanks




Answer this question

writing images from SQL in a table...

  • Robert Liu

    Hi,

    It worked, but instead of print the image it's printing System.Byte[]

    Any Idea

    Here is the code...

    try
    {
    IDataReader dr=cons.consulta_imagem(Request.QueryString["cod"].ToString());
    dr.Read();
    string tipo=dr["Tipo"].ToString();
    byte[] images=(byte[]) dr["Imagem"];
    int tamanho=Convert.ToInt32(dr["Tamanho"].ToString());
    dr.Close();
    Response.Clear();
    Response.Buffer = true;
    Response.Charset = "";
    Response.ContentType = tipo;
    Response.OutputStream.Write(images, 0, tamanho);
    Response.End();
    }
    catch(Exception err){
    Response.Write("<img src='imagens/noimage.jpg' border=0>");
    Response.End();
    }



  • Matthew D Erwin

    Wait. Actually, after reading your initial post, I might have said things incorrectly.

    Where are these images stored again


  • zuz29

    what you'll need to do is make additional http requests to another file that will retrieve the binary from SQL Server, and stream it back to the client. That's the way of the image rendering in web browsers.


  • NormalnesS

    They are stored at SQL Server, I think that the way you said works...

    Thanks...I have these codes already, I'm not at work right now so tomorrow I'm gonna test...and post here the answer

    Thanks a lot

    PS: I haven't thought in this option...lol



  • Anthony Tarlano

    Can you give me an example, I understood,but I just doesn't know how can I get the html from the page that I resquest and print it with the image

    Thanks for helping me



  • Frankboonen

    in the table, you'd do <img src="http://yourdomain.com/image.aspx id=12345" border="0" />

    your image.aspx page will get the id, and retrieve the binary from the database. You change the content type, and forward the byte to the output stream. I don't have code readily available to do that on this machine, but I believe it's all over google.com


  • Roland51

    For good example have a look at Personal Starter Kit 2005 .
  • writing images from SQL in a table...