when i use this code to save my datatable to the databaseit works well on the initial save save but when I access the database fill the datatable and then I delete some rows from the datatable and the "SAVE" the changes are not carried on to the database.How come the changes are not reflecting in the database? what can I do ?

    '******  SAVE PRODUCT RAW MATERIAL DETAILS IN THE GRIDVIEW *****************************
    Dim myConn As OleDbConnection = frmLogIn.Conn
    Dim oledbCmdBuilder As OleDbCommandBuilder
    Dim changes As DataTable
    Dim sql As String = "select * from ProductRawMaterial"
    Dim oledbAdapter As OleDbDataAdapter = New OleDbDataAdapter(sql, myConn)
    oledbCmdBuilder = New OleDbCommandBuilder(oledbAdapter)
    changes = myTable.GetChanges()
    oledbCmdBuilder.ConflictOption = ConflictOption.OverwriteChanges
    If changes IsNot Nothing Then
    End If
    '****************    SAVING TO AUDIT   ******************************************
    Dim myKonn As OleDbConnection = frmLogIn.Connn
    Dim oledbCmdBuilderAudit As OleDbCommandBuilder
    Dim sqlAudit As String = "select * from ProductRawMaterial"
    Dim oledbAdapterAudit As OleDbDataAdapter = New OleDbDataAdapter(sqlAudit, myKonn)
    oledbCmdBuilderAudit = New OleDbCommandBuilder(oledbAdapterAudit)
    oledbCmdBuilderAudit.ConflictOption = ConflictOption.OverwriteChanges
    If changes IsNot Nothing Then
    End If

Be sure to call MyDataSet.AcceptChanges. This tells the underlying class that changes have been made. It also validated the changes. Then call DataAdapter.Update.

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.