Results 1 to 11 of 11

Thread: [RESOLVED] Database not updating

Threaded View

  1. #7

    Thread Starter
    Lively Member
    Join Date
    Sep 2009
    Location
    United States
    Posts
    83

    Re: Database not updating

    Quote Originally Posted by jmcilhinney View Post
    The issue with that last code snippet is the fact that you are calling AcceptChanges, which you weren't in any of the previous code snippets you posted. You will almost never have to call AcceptChanges explicitly.

    By calling AcceptChanges you are saying that all the changes in your DataRow have been saved, so obviously it should only be called after you have actually saved the changes to the database. The thing is, the Update method of a DataAdapter or TableAdapter will call AcceptChanges implicitly, so you will not have to call it yourself in most cases.
    I didn't have to call it previously, but I experienced a problem which wouldn't allow me to update ANY data in the database ( regardless of whether or not I restarted the application ) and calling AcceptChanges seemed to fix it.

    I'll remove AcceptChanges and post results.

    I experience the same problem

    Code:
       Case Events.Debug
    
                    Console.WriteLine("Debug")
    
                    Dim UN As String = DirectCast(Items(1), String)
                    Dim R As LeafDataSet1.UsersRow = DB.Users.FindByUsername(UN)
                    If R IsNot Nothing Then
                        R.Leaves += 10
                        Console.WriteLine("{0} rows were updated", Users.Update(R))
                    End If
    It doesn't seem to run anything past the Console.Writeline without the AcceptChanges method being called.

    Also, if I try to do it again, it doesn't do anything ( Doesn't rewrite Console.Writeline("Debug") ) - this is strange.
    Last edited by GizSho; Jul 28th, 2011 at 09:38 PM. Reason: wrong snippet

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