I'm trying to display name suggestions on a textbox but it's not suggesting anything. I followed a couple tutorials about this but still with the exact same code I cant make it work. I'm using Dapper so maybe I have done something wrong there. Am I missing something?
This is what I have done with Dapper:
public static List<string> DevolverNombres()
{
var dbCon = DBConnection.Instancia();
if (dbCon.Conectado())
{
using (IDbConnection conexion = dbCon.Conexion)
{
var output = conexion.Query($"SELECT nombre FROM usuario;").ToList();
var lista = new List<string>();
foreach (IDictionary<string, object> row in output)
{
foreach (var pair in row)
{
lista.Add(pair.Value.ToString());
}
}
return lista;
}
}
else return null;
}
And this is what I have in the form:
private void Home_Load(object sender, EventArgs e) {
var nombres = AccesoDatos.DevolverNombres();
var lista = new AutoCompleteStringCollection();
foreach(string elem in nombres)
{
lista.Add(elem);
}
txtBuscar.AutoCompleteCustomSource = lista;
}