TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
sam samuel
NA
112
6.5k
Selecting image from database after user login
Mar 1 2017 8:14 AM
i have done for insering and selecting code using handler.ashx for selecting the photo
with the help of button click i get the use photo i want to get when the pageload itself with the help of handler page
///
PhotoHandler.ashx
<%@ WebHandler Language="C#" Class="PhotoHandler" %>
using System;
using System.Web;
public class PhotoHandler : IHttpHandler {
public void ProcessRequest (HttpContext context)
{
{
System.Data.SqlClient.SqlDataReader rdr = null;
System.Data.SqlClient.SqlConnection conn = null;
System.Data.SqlClient.SqlCommand selcmd = null;
try
{
conn = new System.Data.SqlClient.SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["studentConnectionString"].ConnectionString);
selcmd = new System.Data.SqlClient.SqlCommand("select Image from User_Table where id=" + context.Request.QueryString["imgID"], conn);
conn.Open();
rdr = selcmd.ExecuteReader();
while (rdr.Read())
{
context.Response.ContentType = "image/jpg";
context.Response.BinaryWrite((byte[])rdr["Image"]);
}
if (rdr != null)
rdr.Close();
}
finally
{
if (conn != null)
conn.Close();
}
}
}
public bool IsReusable
{
get
{
return false;
}
}
}
Reply
Answers (
2
)
Visual Studio 2015 Error
Selection Is Disgarded When Selecting Same date again...