Click here to Skip to main content
Sign Up to vote bad
good
See more: C#4.0
Pls Help me.Thanks in advance
 

<%@ WebHandler Language="C#" Class="ImageHandler" %>
 
using System;
using System.Web;
using System.Configuration;
using MySql.Data.MySqlClient;
public class ImageHandler : IHttpHandler 
{
 

    string strcon = ConfigurationManager.ConnectionStrings["WelfareDB"].ToString();
    public void ProcessRequest (HttpContext context)
    {
        if (context.Request.QueryString["ImID"] !=null)
        {
            string imgid = context.Request.QueryString["ImID"];
            MySqlConnection con = new MySqlConnection(strcon);
            con.Open();
            string qry = "select image from inchargedetail where inchargeid=@detailid";
            MySqlParameter detailidP = new MySqlParameter("@detailid", imgid);
            MySqlDataReader dr = MySqlHelper.ExecuteReader(con, qry, detailidP);
            dr.Read();
            context.Response.BinaryWrite((Byte[])dr[0]);
            con.Close();
            context.Response.End();
        }
      
    }
 
    public bool IsReusable
    {
        get
        {
            return false;
        }
    }
 
}
Posted 30 Nov '12 - 18:57

Comments
pankajgarg1986 - 1 Dec '12 - 0:58
how to check for system.dbnull in if statement

1 solution

Please see: http://msdn.microsoft.com/en-us/library/system.dbnull.aspx[^],
http://msdn.microsoft.com/en-us/library/system.dbnull.value.aspx[^].
 
For example: DBNull.Value.Equals(someValue); but in general case, first make sure someValue != null.
 
—SA
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 8,123
1 OriginalGriff 6,040
2 CPallini 3,432
3 Rohan Leuva 2,703
4 Maciej Los 2,234


Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 1 Dec 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid