I'm doing a project where I want Data to be saved to a database ALWAYS. :) When Im in debug the data is saved and it is even saved while the program is running and saved after it closes. As soon as i open the program back up the data disappears. I've tried everything..using oledbconnection no go. Using sqlconnection no go. I was getting errors left and right. I looked at the tutorial for oledbconnections. I thought it might be row count? I finally decided to simply use the addnew and save code under the database tools Although that code is alot easier Here's my code:

Public Class MainForm

Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    'TODO: This line of code loads data into the 'CustomerDataSet.Customer' table.
    Me.CustomerTableAdapter.Fill(Me.CustomerDataSet.Customer)

End Sub

Private Sub NCButton_Click(sender As Object, e As EventArgs) Handles NCButton.Click
    Me.CustomerBindingSource.AddNew()
End Sub

Private Sub SaveButton_Click(sender As Object, e As EventArgs) Handles SaveButton.Click
    Me.Validate()
    Me.CustomerBindingSource.EndEdit()
    Me.TableAdapterManager.UpdateAll(Me.CustomerDataSet)
End Sub

End Class

Recommended Answers

All 4 Replies

As soon as i open the program back up the data disappears.

That sounds like you're doing something to truncate the table(s) when the application loads. I'd start by tracing what happens as the application loads in the debugger and keep an eye on the database to narrow down when exactly this data loss occurs.

It happens when I re-open the program. It doesn't save any of the data i imput previously and starts me back at row 0 to save data to. even if i put it at the 3rd row ...row 1 and 2 have disappeared.

What kind of database are you using?

Is it possible that you are updating an in-memory copy of the database that is not getting saved to the actual database?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.