Thursday, March 05, 2015

Auto complete extender in dotnet

[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
   public static List<string> GetCompletionList(string prefixText, int count, string contextKey)
   {
       List<string> s1 = new List<string>();
       SqlConnection cn = new SqlConnection(@"Data Source=ammiforu;Initial Catalog=mail;Integrated Security=True");
       SqlCommand cmd = new SqlCommand("select email from fgetpass where email like @p1+'%'", cn);
       cmd.Parameters.AddWithValue("@p1", prefixText);
       cn.Open();
       SqlDataReader dr = cmd.ExecuteReader();
       while (dr.Read())
       {
           s1.Add(dr[0].ToString());
       }

       return s1;

No comments:

Post a Comment