AutoComplete with JQuery Structured Query

2

I needed to do a query that worked like the following example:

Inprintyoucanseethattypinganitemreturnsstructuredbyneighborhoodandthencity.

Iwantedtobeabletoknowhowtodomyqueryinthisway,structuredbyNeighborhood,CityandStreet.IcanonlyimplementthesimpleformandbindittoTextBox,accordingtothefollowingfile:

publicclassAutocompleteData:IHttpHandler{publicvoidProcessRequest(HttpContextcontext){stringfirstname=context.Request.QueryString["q"];
string sql = "SELECT Bairro FROM [Bairro] where Bairro like '" + Bairro + 
"%' ; ";
string conexao = 
ConfigurationManager.ConnectionStrings["ctString"].ToString();
using (SqlConnection connection = new SqlConnection(conexao))
    using (SqlCommand command = new SqlCommand(sql, connection))
    {
        connection.Open();

        using (SqlDataReader reader = command.ExecuteReader())
        {
            List<string> list = new List<string>();     
            while (reader.Read())
            {
                context.Response.Write(reader[0].ToString() + Environment.NewLine);
            }
        }
    }
}

public bool IsReusable {
    get {
        return false;
    }
}

}
    
asked by anonymous 20.04.2018 / 18:25

0 answers