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.

Thanks for the reply. will try your suggestion and post back.

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

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.