public void ProcessRequest (HttpContext context) { string prefixText = context.Request.QueryString["q"]; using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString = ConfigurationManager .ConnectionStrings["constr"].ConnectionString; using (SqlCommand cmd = new SqlCommand()) { cmd.CommandText = "select Particulars from M_Stock where " + "Particulars 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["Particulars"]) .Append(Environment.NewLine); } } conn.Close(); context.Response.Write(sb.ToString()); } } } public bool IsReusable { get { return false; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)