string branchid = ""; protected void Page_Load(object sender, EventArgs e) { branchid= Session["branchid"].ToString(); Response.ContentType = "image/jpeg"; Stream strm = ShowImage(branchid); byte[] buffer = new byte[4096]; int byteSeq = strm.Read(buffer, 0, 4096); while (byteSeq > 0) { Response.OutputStream.Write(buffer, 0, byteSeq); byteSeq = strm.Read(buffer, 0, 4096); }Image1.imageurl=byteSeq;}public Stream ShowImage(string branchid) { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Safa"].ConnectionString); string sql = "SELECT imgleft1 FROM tblImages WHERE BranchId = @BranchId"; SqlCommand cmd = new SqlCommand(sql, con); cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("@BranchId", branchid); con.Open(); object img = cmd.ExecuteScalar(); try { return new MemoryStream((byte[])img); } catch { return null; } finally { con.Close(); } }