LN10 Posted June 4, 2012 at 09:20 AM Report Share #460189 Posted June 4, 2012 at 09:20 AM (edited) Bom dia. Tenho este código em que deveria fazer uma pesquisa na Tabela "Programas", só que parece que o código não corre. Não dá erro nenhum, simplesmente não faz a sua função. <title></title> <script src="js/jquery-latest.js" type="text/javascript"></script> <link rel="stylesheet" href="css/jquery.autocomplete.css" type="text/css" /> <script type="text/javascript" src="js/jquery.autocomplete.js"></script> <script type="text/javascript"> $(document).ready(function () { $("#txtCodProg").autocomplete("Cod_Prog.ashx"); }); </script> ashx <%@ WebHandler Language="C#" Class="Cod_Prog" %> using System; using System.Web; using System.Web.Services; using System.Data; using System.Data.SqlClient; using System.Collections.Generic; using System.Configuration; public class Cod_Prog : IHttpHandler { public void ProcessRequest(HttpContext context) { string pesq_cod = context.Request.QueryString["q"]; string sql = "Select * from Programas where Codigo Like '%" + pesq_cod + "%'"; using (SqlConnection connection = new SqlConnection("Data Source=LN\\Digisoft;Initial Catalog=Registos;Integrated Security=True")) using (SqlCommand command = new SqlCommand(sql, connection)) { connection.Open(); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { context.Response.Write(reader.GetInt32(0) + Environment.NewLine); } } } } public bool IsReusable { get { return false; } } } Edited June 4, 2012 at 10:47 PM by Caça GeSHi Link to comment Share on other sites More sharing options...
renafi Posted June 4, 2012 at 05:59 PM Report Share #460364 Posted June 4, 2012 at 05:59 PM Experimenta por um alert logo no inicio da função javascript para ver se dispara mesmo Oracle Certified Professional - AdministraçãoOracle Certified Professional - Pl/sqlMCPD - Microsoft Certified Professional DeveloperMCTS - Microsoft Certified Technology Specialist Link to comment Share on other sites More sharing options...
LN10 Posted June 5, 2012 at 08:27 AM Author Report Share #460456 Posted June 5, 2012 at 08:27 AM Como posso por um alert? Link to comment Share on other sites More sharing options...
bruno1234 Posted June 5, 2012 at 07:14 PM Report Share #460668 Posted June 5, 2012 at 07:14 PM Estás a escrever os dados na resposta um por linha com uma mudança de linha do sistema operativo (\r\n no caso do windows). Tipo: Resultado1 Resultado2 Resultado3 Não me lembro ao certo o que o plugin precisa, mas penso que não é isso, mas sim um array em json ou xml. Matraquilhos para Android. Gratuito na Play Store. https://play.google.com/store/apps/details?id=pt.bca.matraquilhos Link to comment Share on other sites More sharing options...
LN10 Posted June 6, 2012 at 09:01 AM Author Report Share #460802 Posted June 6, 2012 at 09:01 AM Não estou a perceber Link to comment Share on other sites More sharing options...
rumbafum Posted June 6, 2012 at 12:14 PM Report Share #460847 Posted June 6, 2012 at 12:14 PM isto: context.Response.Write(reader.GetInt32(0) + Environment.NewLine); Não vale nada. Para além de o plugin autocomplete provavelmente não funcionar, não passas muito provavelmente os valores que precisas. Diria que queres passar um id e um campo de texto para usar no autocomplete e com este código passas na melhor das hipóteses o id apenas Precisas escrever json ou xml para a resposta como o bruno1234 já disse. Já te respondi a esta mesma questão em outros tópicos e já te enviei mensagem com um exemplo de código para resolveres o problema. Melhor melhor só se me pagares para te fazer isso lol Link to comment Share on other sites More sharing options...
LN10 Posted June 8, 2012 at 08:50 AM Author Report Share #461299 Posted June 8, 2012 at 08:50 AM Acho estranho pois já tive codigo semelhante a este correr desta forma. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now