Hi,
This sample code for retrieve images from database and display on web page. And videos or images everything need to convert to byte array forma after that we can store or retrieve.
Use this sample,
public class Retrieve : IHttpHandler
{
public void ProcessRequest (HttpContext context)
{
if (context.Request.QueryString != null)
{
string connectionString = ConfigurationManager.AppSettings["ConnectionString"].ToString();
SqlConnection dbConnection = new SqlConnection(connectionString);
string personid = context.Request.QueryString["PID"];
dbConnection.Open();
SqlCommand command = new SqlCommand("SELECT Photo FROM [ProspectDetail] WHERE PersonID = " + personid, dbConnection);
SqlDataReader dr;
if (personid != null)
{
dr = command.ExecuteReader();
while (dr.Read())
{
try
{
byte[] bt = (byte[])dr["Photo"];
if (bt.GetLength(0) != 0)
{
context.Response.BinaryWrite((byte[])dr["Photo"]);
}
}
catch (SqlException exe)
{
ErrorLog err = new ErrorLog();
err.GetErrorLog(exe.Message);
}
finally
{
dbConnection.Close();
context.Response.End();
}
}
}
}
//context.Response.ContentType = "text/plain";
//context.Response.Write("Hello World");
}
public bool IsReusable
{
get
{
return false;
}
}
}