Getting Values from DataSet DataTable RRS feed

  • Question

  • 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;
                EventDBDataSetTableAdapters.ContactsTableAdapter contactsTableAdapter =
                    new EventDBDataSetTableAdapters.ContactsTableAdapter();

    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();

    What i'm missing here ?

    Friday, November 29, 2019 12:37 PM

All replies

  • Hi Arunoda,
    I checked your second paragraph of code and it didn’t return null in my test.
    You can try to set a breakpoint to check if the values in the table.
    Best Regards,
    Daniel Zhang

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, December 2, 2019 6:30 AM