Results 1 to 5 of 5

Thread: Data update is not saved in VB.NET application

  1. #1
    Join Date
    May 2009
    Posts
    640

    Data update is not saved in VB.NET application

    I try to add/edit records in a DataGridView in VB.Net. The addition/modification performed at DGV, and also at the database. However, when I close the application and I recover, my additions/modifications are not saved, I found my old data.

    Here is my code
    Code:
     cmdInsert.CommandType = CommandType.Text
     cmdInsert.CommandText = "insert into File values('" & txtcod.Text & "','" & txtno.Text & "','" & txtfoct.Text & "', '" & Txtbas.Text & "' )"
    cmdInsert.Connection() = myConnection 
    cmdInsert.ExecuteNonQuery()
    cnx.Close()
    MessageBox.show("Listing added correctly")

  2. #2
    Join Date
    Nov 2005
    Posts
    1,323

    Re: Data update is not saved in VB.NET application

    So stupid question, but:
    - Is what the code is reached (in debug mode)
    - If it is reached, is that the database is updated?

  3. #3
    Join Date
    May 2009
    Posts
    640

    Re: Data update is not saved in VB.NET application

    Yes the code is reached. The database is updated too. The problem is that when I restart a second time running the application, I can not find my data inserted. The data are added after they are gone after a second run. In the load of the page that contains the DataGridView (DGV), I have a DataSet. Here is my code:
    Code:
    Try
                connect()
                sql = "select * from File"
                cmd.CommandText = sql
                cmd.Connection() = myConnection
                myDataAdapter.Fill(myDataSet, "File")
                myDataTable = myDataSet.Tables("File")
     
                MyDGV.DataSource = myDataTable

  4. #4
    Join Date
    Nov 2008
    Posts
    1,221

    Re: Data update is not saved in VB.NET application

    A commit will be better:
    Code:
     cmdInsert.CommandType = CommandType.Text
     cmdInsert.CommandText = "insert into File values('" & txtcod.Text & "','" & txtno.Text & "','" & txtfoct.Text & "', '" & Txtbas.Text & "' )"
    cmdInsert.Connection() = maConnection 
    cmdInsert.ExecuteNonQuery()
    cmdInsert.Commit()
    cnx.Close()
    MessageBox.show("Listing added correctly")

  5. #5
    Join Date
    May 2009
    Posts
    640

    Re: Data update is not saved in VB.NET application

    Thanks for you comment but commit is useless for me. I use no transactions and my database is not read only either. If I am correct commit is of no use if no transaction has been started.

    What I have noticed is that all my changes are made in the database, but they are not saved. Indeed, everything is included if I relaunch the project. However, my code is the same used in another project and another database.

    Then do you think this can be because of my Access used for database?

Similar Threads

  1. Saved data is lost in trine 2.
    By Joyendu in forum Video Games
    Replies: 6
    Last Post: 16-12-2011, 02:47 AM
  2. Batman: Arkham City saved data corrupted in PS3
    By Urjavaha in forum Video Games
    Replies: 3
    Last Post: 19-11-2011, 10:42 PM
  3. Replies: 7
    Last Post: 04-09-2011, 11:16 PM
  4. Data access principal for . NET application
    By Christina 80 in forum Software Development
    Replies: 5
    Last Post: 12-02-2010, 01:20 AM
  5. What are the Application of data mining?
    By roodiii in forum Software Development
    Replies: 3
    Last Post: 26-11-2009, 09:17 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,251,103.57392 seconds with 17 queries