hi all,
Here is my code to insert and update my Access database.
Problem is after the data gets updated, after a while, all the records in the database disapears...??? I am quite confused....pl help whth my code..thanks

Dim icode As Integer
        frmEdit_Items.ITEMTableAdapter.Insert(Me.TextBox1.Text, Me.TextBox2.Text, Me.TextBox3.Text)
        frmEdit_Items.ITEMTableAdapter.Fill(frmEdit_Items.KiranSDBDataSet.ITEM)
        frmEdit_Items.ITEMTableAdapter.Update(frmEdit_Items.KiranSDBDataSet.ITEM)

        icode = Val(Me.TextBox1.Text)
        If RadioButton1.Checked = True Then

            frmEdit_Items.SPORTS_ITEMTableAdapter.Insert(icode, Me.txttype.Text, Me.txtsportsitemt.Text, Me.txtsportss.Text)
            frmEdit_Items.SPORTS_ITEMTableAdapter.Fill(frmEdit_Items.KiranSDBDataSet.SPORTS_ITEM)
            frmEdit_Items.SPORTS_ITEMTableAdapter.Update(frmEdit_Items.KiranSDBDataSet.SPORTS_ITEM)
            'frmEdit_Items.KiranSDBDataSet.AcceptChanges()
        ElseIf RadioButton2.Checked = True Then
            frmEdit_Items.STATIONERY_ITEMTableAdapter.Insert(icode, Me.txtstationarys.Text)
            frmEdit_Items.STATIONERY_ITEMTableAdapter.Fill(frmEdit_Items.KiranSDBDataSet.STATIONERY_ITEM)
            frmEdit_Items.STATIONERY_ITEMTableAdapter.Update(frmEdit_Items.KiranSDBDataSet.STATIONERY_ITEM)
            'frmEdit_Items.KiranSDBDataSet.AcceptChanges()
        End If
        frmEdit_Items.KiranSDBDataSet.AcceptChanges()

You insert a record, then call fill before update? Why? The fill method clears out changes that haven't been committed to the database.

I am also finding it difficult to write the code to check the DB for duplicate code before i insert a new record

This article has been dead for over six months. Start a new discussion instead.