<%@ WebHandler Language="C#" Class="AutoCompleteData" %>
using System;
using System.Web;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using System.Configuration;
public class AutoCompleteData : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        string prefixText = context.Request.QueryString["q"];
        using (SqlConnection conn = new SqlConnection())
        {
            conn.ConnectionString = "Data Source=ANGLER97\\SQL2008;Initial Catalog=TimecheckV1_TestingDB;uid=sa;";
            using (SqlCommand cmd = new SqlCommand())
            {
                cmd.CommandText = "select swipecardNo from TA_Tbl_Employee where " +
                "swipecardNo like @SearchText + '%'";
                cmd.Parameters.AddWithValue("@SearchText", prefixText);
                cmd.Connection = conn;
                StringBuilder sb = new StringBuilder();
                conn.Open();
                using (SqlDataReader sdr = cmd.ExecuteReader())
                {
                    while (sdr.Read())
                    {
                        sb.Append(sdr["swipecardNo"])
                            .Append(Environment.NewLine);
                    }
                }
                conn.Close();
                context.Response.Write(sb.ToString());
            }
        }
    }
    public bool IsReusable
    {
        get
        {
            return false;
        }
    }
}