Results 1 to 2 of 2

Thread: [RESOLVED] How to cancel .AddNew()

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2008
    Posts
    92

    Resolved [RESOLVED] How to cancel .AddNew()

    I have a form and use it to add contact information to a database. Name, Address, etc. My question is there a way to cancel the addNew method.

    clientBindingSource.AddNew()

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How to cancel .AddNew()

    The short answer is CancelEdit.

    The long answer is that calling AddNew creates a new DataRowView and adds it to the DefaultView of your DataTable without actually adding the corresponding DataRow to the DataTable itself. To commit the change and add the row you call EndEdit, while to rollback the change and discard the row you call CancelEdit. Note that, in bound controls, pressing the Escape key will invoke the CancelEdit method while navigating away from the row will invoke the EndEdit method.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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