Sybase issue

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ben G
    New Member
    • Oct 2010
    • 3

    Sybase issue

    Hi All,

    I am new to .NET programming and I am writing an application that gets some data from Sybase DB then displays it in the UI. So far this is what I have. The problem is that the data does not seem to be stored in the collections and therefore cannot be diplayed in the UI. Would appreciate any help. Thanks!

    Code:
    public partial class MainWindow : Window
    	{
    		public MainWindow()
    		{
    			this.InitializeComponent();
    
    			// Insert code required on object creation below this point.
    		}
            private List<Party> LoadPartyData()
            {
                List<Party> teams = new List<Party>();
    
                return teams;
            }
            private List<Person> LoadPersonData()
            {
                List<Person> analysts = new List<Person>();
    
                return analysts;
            }
    
            private Party CreateParty(int PartyID, string PartyName)
            {
                Party party = new Party();
                party.PartyID = PartyID;
                party.PartyName = PartyName;
                
                return party;
            }
    
            private Person CreatePerson(int PersonID, string FullName)
            {
                Person person = new Person();
                person.PersonID = PersonID;
                person.FullName = FullName;
         
                return person;
            }
    
            public void GetData()
            {
                List<Party> teams = new List<Party>();
                List<Person> analysts = new List<Person>();
    
                AseConnection connection = new AseConnection("Data Source=london01data.com;Port=0000;Database=data_sybase;Uid=user01;Pwd=pass01;");
    
                AseCommand command = new AseCommand("SELECT TOP 100 party_group_id, party_group_name FROM PartyGroup");
                AseCommand command2 = new AseCommand("SELECT TOP 100 person_id, full_name FROM Person");
    
                command.Connection = connection;
                command2.Connection = connection;
                
                connection.Open();
    
                using (AseDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        Party party = new Party();
                        party.PartyID = Convert.ToInt32(reader["party_group_id"]);
                        party.PartyName = reader["party_group_name"].ToString();
    
                        teams.Add(party);
    
                        //Console.WriteLine(reader["full_name"].ToString());
                    }
                }
    
                using (AseDataReader reader = command2.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        //if(reader["full_name"] != DBNull.Value)
                        //  analysts.Add(reader["full_name"].ToString());                    
                            Person person = new Person();
                            person.PersonID = Convert.ToInt32(reader["person_id"]);
                            person.FullName = reader["full_name"].ToString();
    
                        analysts.Add(person);
                    }
                }
                connection.Close();
    
            
            }
    Last edited by Curtis Rutland; Nov 9 '10, 02:37 PM.
Working...