I have a list of contacts with Id, Name, Adress etc. and i want to do a query to return all those contacts.
public List<MyAgenda> mostrarContatos()
{
MyAgenda ma = new MyAgenda();
DataSet ds = new DataSet();
OleDbConnection conn = new OleDbConnection();
try
{
conn = new OleDbConnection(ConfigurationManager.ConnectionStrings["myconn"].ConnectionString);
//2ª Passo: Definir query
string query = "select * from Table where Id like '" + ma.Id + "%'";
//3ª Passo: Preprarar para Executar
OleDbDataAdapter da = new OleDbDataAdapter(query, conn);
//4º Passo: Executa a query
da.Fill(ds, "Dados");
//Devolvo DataSet
return ds;
}
catch (Exception err)
{
throw new Exception("ERRO: " + err.Message);
}
finally
{
conn.Close();
}
It seems i cant return the Ds and im not sure if my query is totally correct. Any help please?