Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Pls Help me.Thanks in advance


C#
<%@ 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
Comments
pankajgarg1986 1-Dec-12 0:58am    
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
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900