currencyManager.removeAt problem

alander

Well-known member
Joined
Jun 26, 2007
Messages
120
Location
Singapore
Programming Experience
5-10
hi, i wanna delete a record from a MS ACCESS database, when i click the button delete, everything shows beautifully,

however when i load the form again, the record doesnt go away, the add new does commit but the delete doesn't..

any help will be greatly appreciated


VB.NET:
 cmItem.EndCurrentEdit()
        If MessageBox.Show("Delete Current Record", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
            cmItem.RemoveAt(cmItem.Position)
        Else
            MessageBox.Show("Record Not Deleted", "Not Deleted", MessageBoxButtons.OK, MessageBoxIcon.Information)
        End If
 
o thanks lol
 
Youre usiong .NET 2.0, you shouldnt be using the currencymanager ; its a hidden part of the binding source. If you are using it, it indicates youre following some old tutorial. Take a read of the DW2 link in my signature, for tips on the new ways of .NET data access - read the Creating a Simple Data App section, it covers all the basics including deleting data

RemoveAt removes the row from the data table. If you dont know the difference between a datatable and the database, read the sticky in the ADO.NET forum. RemoveAt does not mark a row for Deletion

Use whateverRow.Delete() to mark a row as deleted


There's a big difference between removing a row so the local ADO.NET is no longer aware of its existence, and keeping the row but marking it as deleted so that the local ADO.NET tells the database to delete it.
 
Youre usiong .NET 2.0, you shouldnt be using the currencymanager ; its a hidden part of the binding source. If you are using it, it indicates youre following some old tutorial. Take a read of the DW2 link in my signature, for tips on the new ways of .NET data access - read the Creating a Simple Data App section, it covers all the basics including deleting data

RemoveAt removes the row from the data table. If you dont know the difference between a datatable and the database, read the sticky in the ADO.NET forum. RemoveAt does not mark a row for Deletion

Use whateverRow.Delete() to mark a row as deleted


There's a big difference between removing a row so the local ADO.NET is no longer aware of its existence, and keeping the row but marking it as deleted so that the local ADO.NET tells the database to delete it.


i was trained in framework 1.0.. but recently asked to do a 2.0 project.. so i used the old way.. thx for ur tip
 
Back
Top