data not adding to database properly!

ninjaimp

Well-known member
Joined
Jun 13, 2007
Messages
80
Programming Experience
1-3
Hi

I have a form which adds data to a dataset, which can be viewed in a datagrid as it happens and then they finish and this adds it to the database - but after a short while the data that was added seems to rdissapear ffrom the database! Wondered if anyone could see where i may have gpne wrong!

VB.NET:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim drNew As System.Data.DataRow

        drNew = Me.UrlsDataSet.AllowedUrls.NewRow
        drNew.Item("URL") = urlTextBox.Text
        Me.UrlsDataSet.AllowedUrls.Rows.Add(drNew)

        Changes = True
        
    End Sub

    Sub AddData() ' add the new urls to the database

        Me.Validate()
        Me.AllowedUrlsBindingSource.EndEdit()
        Me.AllowedUrlsTableAdapter.Update(Me.UrlsDataSet.AllowedUrls)

        MsgBox("All new data added successfully!")

        Me.Close()

    End Sub
 
thanks for your response and the link. It is early and dont think i have woken up properly but im trying to understand where i need to go.

I am using a local database, as far as i can tell and the odd thing is when i make changes they stay there for awhile - i mean that i can close the application and open it for debugging a few times before the data dissapears!

thanks for your help
 
Read the DNU link in my signature. Likely you have set "Copy if newer". It stays there a few times because your db doesnt change those few times, but then after you make a change that causes the last-modified date of the db file to change, it is copied out again, "erasing" your data
 
hi

no i have checked, and it is set to 'Cop Always' - on closer inspection it seems that there is some problem with the Event Log File being full so have just increased the file size but not sure if that is connected!

Its really annying cos i cant make any sense of it!
 
ok, if it's set to copy always and your data persists at least some time, then either the database is locked/in use and cannot be replaced and is periodically released, or a build is not being performed each time you debug
 
sorry, i kind of jumped the gun first then and have now had a look at your link which of course explains exactly my problem - So assuming that in my app i can see the data being added as it is in a datgrid i can safely assume that when i publish the project it should work ok?

many thanks for your help
 

Latest posts

Back
Top