public DataTable GetContato(int id) { DbConnection conexao = DAOUtils.GetConexao(); DbCommand comando = DAOUtils.GetComando(conexao); comando.CommandType = CommandType.Text; comando.CommandText = "SELECT * FROM CONTATOS WHERE ID = @id"; comando.Parameters.Add(new SqlParameter("@id", id)); DbDataReader reader = DAOUtils.GetDataReader(comando); DataTable dataTable = new DataTable(); dataTable.Load(reader); return(dataTable); }
public DataTable GetContatos() { DbConnection conexao = DAOUtils.GetConexao(); DbCommand comando = DAOUtils.GetComando(conexao); comando.CommandType = CommandType.Text; comando.CommandText = "SELECT * FROM CONTATOS"; DbDataReader reader = DAOUtils.GetDataReader(comando); DataTable dataTable = new DataTable(); dataTable.Load(reader); return(dataTable); //DbDataAdapter adapter = new SqlDataAdapter((SqlCommand)comando); //DataSet ds = new DataSet(); //adapter.Fill(ds, "CONTATOS"); //return ds; }