Getting Values from DataSet DataTable

Nov 29 2019 6:50 AM
I have a dataset called EventDBDataSet and there is a datatable called contacts in that dataset. I use following code to store data to contacts datatable and it works fine.
 
 EventDBDataSet eventDBDataSet = new EventDBDataSet(); EventDBDataSet.ContactsRow contactsRow = eventDBDataSet.Contacts.NewContactsRow();              contactsRow.contactName = contact.contactName;             contactsRow.contactNumber = contact.contactNumber;              eventDBDataSet.Contacts.Rows.Add(contactsRow); EventDBDataSetTableAdapters.ContactsTableAdapter contactsTableAdapter = new EventDBDataSetTableAdapters.ContactsTableAdapter();              contactsTableAdapter.Update(eventDBDataSet.Contacts);              eventDBDataSet.Contacts.AcceptChanges();
 Then i try to get those contacts details using following code and it returns null.
 
DataRow[] dataRows = eventDBDataSet.Contacts.Select(); foreach (DataRow dr in dataRows) {                  contactName = dr["contactName"].ToString(); MessageBox.Show(contactName); }
 

Answers (1)