I did this a few months ago but here is the code I used.
private void Page_Load(object sender, System.EventArgs e)
dbConn = new System.Data.SqlClient.SqlConnection(ConfigurationSettings.AppSettings["connString"]);
string id = Request.QueryString["id"];
string sCmd = "SELECT Photo FROM t_Student_Photos WHERE Photo_Id =" + id;
cmd = new System.Data.SqlClient.SqlCommand(sCmd, dbConn);
dbReader = cmd.ExecuteReader();
//Reponse.Content type would have to change depending on the type of image
Response.ContentType = "image\\jpeg";
And then you would simply put viewimage.aspx?id=1234 as the src in your img tag and it would load the required image from the database.
This probably is not the best or most flexible code buit it does work.