Ver Mensaje Individual
  #2 (permalink)  
Antiguo 30/07/2010, 17:57
Avatar de triqui
triqui
 
Fecha de Ingreso: diciembre-2008
Ubicación: Zaragoza(España)
Mensajes: 624
Antigüedad: 15 años, 4 meses
Puntos: 31
Respuesta: Error al llenar un array con db

Autocomplete de ajax muy bueno...jejeje yo lo tengo implementado y a las mil maravillas, te pongo mi codigo... de vb no te puedo pasar nada, lo tengo desarrollado en c# por si te sirve. te lo copio.




Código:
  public string[] BuscarPeople(string prefixText)
    {
        Database objDB = null;
        objDB = DatabaseFactory.CreateDatabase("ConnectionString");
        List<string> responses = new List<string>();
        string SQL_Select = "select TOP 15 Alias from TUsuario where Alias like '"+prefixText+"%' order by Alias";
        try
        {
            DbCommand objCmd = objDB.GetSqlStringCommand(SQL_Select);
            IDataReader objDR = objDB.ExecuteReader(objCmd);
            int count = 0;
            while (objDR.Read())
            {

                responses.Add(objDR[0].ToString());

            }
           
        }
        catch (Exception EX)
        {

        }
        finally
        {

        }
        return responses.ToArray();
    }
EL WS que llama a la funcion BuscarPeople()

Cita:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Script.Services;
using System.Data;

/// <summary>
/// Summary description for MyAutocompleteService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]

// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class MyAutocompleteService : System.Web.Services.WebService {

public MyAutocompleteService () {

//Uncomment the following line if using designed components
//InitializeComponent();
}

[WebMethod]

public string[] GetSuggestions(string prefixText, int count)
{

CSConexionPena _csConexion = new CSConexionPena();

string[] responses = _csConexion.BuscarPeople(prefixText);

return responses.ToArray();

}

}

Y los controles del diseño...

Cita:
<cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" ServicePath="MyAutocompleteService.asmx" ServiceMethod="GetSuggestions" TargetControlID="Txtdestinatario" MinimumPrefixLength="0" CompletionSetCount="12" DelimiterCharacters=";, :" CompletionListCssClass="list2" CompletionListItemCssClass="listitem2" CompletionListHighlightedItemCssClass="hoverlistit em2" SkinID="green" EnableCaching="true"></cc1:AutoCompleteExtender>

<asp:TextBox ID="Txtdestinatario" runat="server" Height="20px"
Width="300px" autocomplete="off" ></asp:TextBox>
Haber si te sirve...
__________________
La nueva red social de quinielas quiniela resultados
Cazaresultados Futbol base en directo