make a ashx handler file and put similar code in it
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace DemoCode
{
public class Demo : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
methods.createcon("forum");
SqlCommand dispimgcmd = new SqlCommand("select * from reginfo where userid=" + "'" + Session["mlinkquid"] + "'", methods.connection);
SqlDataReader drdispimg = dispimgcmd.ExecuteReader();
drdispimg.Read();
Response.Buffer = true;
Response.Clear();
Response.ContentType = (string)drdispimg["imgstrtype"];
Response.OutputStream.Write((byte[])drdispimg["imgdata"], 0, (int)drdispimg["imgsize"]);
methods.connection.Close();
Response.End();
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
then add an image to you page and point it to the handler file for it's source
<pre lang="HTML"><img src="/Demo.ashx" />
obviously you'd want to add querystrings after ashx eg: src='/Demo.ashx?imageID=45'.
Also please note that the select * should be on the main page and you would in the handler file receive imageID from the querystring and that's the image you'd write out