0 Replies - 2469 Views - Last Post: 05 March 2012 - 05:06 AM

#1 polens  Icon User is offline

  • D.I.C Head

Reputation: 13
  • View blog
  • Posts: 155
  • Joined: 09-November 09

problem in httphandler

Posted 05 March 2012 - 05:06 AM

i cant seem to get the handler to work.. its and image handler..
here is the code:
  public void ProcessRequest(HttpContext context)
        {
            SqlConnection myConnection = new SqlConnection();
            myConnection.ConnectionString = WebConfigurationManager.ConnectionStrings
                                   ["dbWebProgConnectionString"].ConnectionString.ToString();

            string sql = "Select * from tblProduct where PID=@PID";
            SqlCommand cmd = new SqlCommand(sql, myConnection);
            cmd.Parameters.Add("@PID", SqlDbType.BigInt).Value = context.Request.QueryString["id"];
            myConnection.Open();
            cmd.Prepare();
            SqlDataReader dr = cmd.ExecuteReader();
            dr.Read();
            context.Response.ContentType = dr["PName"].ToString();
            context.Response.BinaryWrite((byte[])dr["PImage"]);
            dr.Close();
            myConnection.Close(); 
        }



 <img src='<%# "Handler.ashx?id=1000"%>'
                        height="120" width="120" />

basically what i did was in the controller i just selected all the data from database..
then in the view
i just added a new column
and the call httphandler but its not working

is there any way to populate image data from database to view or from model?
please enlighten me on this one

Is This A Good Question/Topic? 0
  • +

Page 1 of 1