"Select (nome,' ',bino) as u_nome From cve "
That SQL query doesn't look right - if you're using MS SQL, you can't just wrap multiple values in brackets and expect SQL to concatenate them.
if (ds.Tables[0].ToString().ToLower().StartsWith(prefixText.ToLower()))
You're also only returning any data if the
name of the first table starts with the prefix - you should be comparing the value instead.
Rather than reading every record from the table into memory and then using C# to filter and sort them, you should use SQL:
[WebMethod]
public string[] AutoCompleteSearch(string prefixText, int count)
{
using (SqlConnection connection = new SqlConnection("YOUR CONNECTION STRING HERE"))
using (SqlCommand command = new SqlCommand("SELECT TOP (@Count) nome + ' ' + bino As u_nome From cve Where nome + ' ' + bino Like @Prefix Order By nome, bino", connection))
{
command.Parameters.AddWithValue("@Prefix", prefixText + "%");
command.Parameters.AddWithValue("@Count", count);
connection.Open();
using (SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection | CommandBehavior.SingleResult))
{
List<string> result = new List<string>(count);
while (reader.Read())
{
result.Add(reader.GetString(0));
}
return result.ToArray();
}
}
}