Hi there!
I have a running project that uses this extension quering data from a database that works just fine.
This is my aspx block:
<asp:TextBox ID="edCliente" runat="server" MaxLength="50" Width="250px" ValidationGroup="cabecalho"></asp:TextBox>
<cc1:AutoCompleteExtender
ID="AutoCompleteClientes" runat="server"
Enabled="True" TargetControlID="edCliente"
ServiceMethod="PesquisaClientesProposta" ServicePath="~/AutoCompleteClientes.asmx"
CompletionSetCount="12" MinimumPrefixLength="1"
CompletionInterval="0">
</cc1:AutoCompleteExtender>
And this is the asmx code:
[WebMethod]
public string[] PesquisaClientesProposta(string prefixText)
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["prodMIS"].ToString();
conn.Open();
StringBuilder ComandoSQL = new StringBuilder();
ComandoSQL.AppendLine("SELECT DISTINCT NOME_CLIENTE NOME FROM MIS..CONTRACT CTR ");
ComandoSQL.AppendLine("WHERE CTR.NOME_CLIENTE LIKE @NOME ");
ComandoSQL.AppendLine("ORDER BY NOME_CLIENTE ");
SqlParameter ParamNome = new SqlParameter("NOME", System.Data.SqlDbType.VarChar, 35, "NOME");
ParamNome.Value = String.Concat(prefixText, "%");
SqlCommand CMD = new SqlCommand(ComandoSQL.ToString(), conn);
CMD.Parameters.Add(ParamNome);
SqlDataAdapter SQLda = new SqlDataAdapter(CMD);
SqlCommandBuilder CMDbuilder = new SqlCommandBuilder(SQLda);
SqlDataReader SQLReader;
SQLReader = CMD.ExecuteReader();
List<string> listClientes = new List<string>();
while (SQLReader.Read())
{
listClientes.Add(SQLReader["NOME"].ToString());
}
conn.Close();
return listClientes.ToArray();
}
I don't know if that helps you, but it's working fine for me.
Regards,
Obst