I used this coding for retrieve image from database and bind it to the image control inside data list, this code already worked properly ,now i am used another one application it not read a binary values from database.. what the problem..
server side coding:
Da_Layer DL = new Da_Layer();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string query = "select * from gallery";
DataSet ds = DL.Grid(query);
DataList1.DataSource = ds.Tables[0];
DataList1.DataBind();
}
}
ImageHandler.ashx coding:
<%@ WebHandler Language="C#" Class="ImageHandler" %>
using System;
using System.Web;
using System.Data.SqlClient;
public class ImageHandler : IHttpHandler {
Da_Layer DL = new Da_Layer();
public void ProcessRequest (HttpContext context)
{
//context.Response.ContentType = "text/plain";
//context.Response.Write("Hello World");
string query = "select * from gallery where gname='"+context.Request.Params["id"]+"'";
SqlDataReader dr = DL.ExecuteReader(query);
dr.Read();
Byte[] Imagedata = (byte[])dr["gphoto"];
// context.Response.BinaryWrite(dr["gphoto"]);
context.Response.BinaryWrite(Imagedata);
dr.Close();
}
public bool IsReusable {
get {
return false;
}
}
}
i change context.Request.Params["id"] and directly give input for select query and
i run ImageHandler.ashx it give the Output System.byte[]
but correct answer it need to give some binary values in browser
What is the problem...... in this application i used both c# and vb
also i used this coding for convert binary value from database to image,it also not give correct answer,my question is if i want read binary value any change need web.config file
i change context.Request.Params["id"] and directly give input for select query and
i run ImageHandler.ashx it give the Output System.byte[]
but correct answer it need to give some binary values in browser
What is the problem...... in this application i used both c# and vb
also i used this coding for convert binary value from database to image,it also not give correct answer,my question is if i want read binary value any change need web.config file
DL.OpenConnection();
FileStream fs = new FileStream(@"c:\xx.jpg", FileMode.CreateNew, FileAccess.Write);
cmd = new SqlCommand("select * from staffdetails where staff_id='" + txt_id.Text + "'", DL.connection);
dr = cmd.ExecuteReader();
if (dr.Read())
{
byte[] b = (byte[])(dr["photo"]);
fs.Write(b, 0, b.Length);
}
fs.Close();
DL.CloseConnection();
GridView1.Visible = false;
DetailsView1.Visible = true;
DetailsView1.DataBind();

Jaganathan BantheswaranPosted Feb 24, 2011, 5:49 AM
Try the code which is attached with this reply.
Arul SelvanPosted Feb 24, 2011, 6:40 AM
Thanks friend really good i learnt lot.....
i am doing MCA final year in my project i want another one help Do You know how to display Calender control in smaill size
here i attached example
Suthish NairPosted Feb 24, 2011, 5:49 AM