CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2009
    Posts
    19

    [RESOLVED] Data not being written to Datarow

    First I select a datarow using:
    Code:
    datarow[] rowtochange = datarow.select["ID = "+variable];
    and the edit it with
    Code:
    rowtochange.beginedit();
    rowtochange[0]["column_1"] = ... ;
                   .
                   .
                   .
    rowtochange.endedit();
    rowtochange.acceptchanges();
    the data runs without error, and yet no data gets changed.
    why is this?

    using .net 3.5

  2. #2
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    Re: Data not being written to Datarow

    Quote Originally Posted by soandos View Post
    First I select a datarow using:
    Code:
    datarow[] rowtochange = datarow.select["ID = "+variable];
    and the edit it with
    Code:
    rowtochange.beginedit();
    rowtochange[0]["column_1"] = ... ;
                   .
                   .
                   .
    rowtochange.endedit();
    rowtochange.acceptchanges();
    the data runs without error, and yet no data gets changed.
    why is this?

    using .net 3.5
    At first this code cannot work as you have case senstive errors in it like we normally would have AcceptChanges();
    But acceptChanges is called after you have written back your data to the database using DataAdapter. So before calling AcceptChanges you need to update your database using that Adapter then when this has had success, you can use AcceptChanges() If you accept the chages all the internal flags that data have changed are cancelled so the database seems to be up to date and when you try to update Database after calling AcceptChanges() it will not find any Recordset that is known as changed.
    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

  3. #3
    Join Date
    Aug 2009
    Posts
    19

    Re: Data not being written to Datarow

    Thank you very much.
    Last edited by soandos; September 6th, 2009 at 09:23 PM. Reason: Error on my part

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