CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2011
    Posts
    63

    Can't add DataRow to DataTable

    Hello,

    I'm having trouble adding a DataRow to a DataTable.

    I create the DataRow like so:

    DataRow row = myDataTable.NewRow();

    I add things to the row, then I try to add the row back to the table:

    myDataTable.Rows.Add(row);

    It tells me: "This row already belongs to this table."

    Ironically, if I try:

    row.AcceptChanges();

    it tells me: "Cannot perform this operation on a row not in the table."

    so is it in the table or is it not?

    myDataTable.AcceptChanges() seems to run without any exceptions, but my table is still empty.

    What gives?

  2. #2
    Join Date
    May 2002
    Posts
    511

    Re: Can't add DataRow to DataTable

    Please share the code that updates the columns within the row with data.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured