Data adapter problem

DougGerlach

Member
Joined
Jun 18, 2008
Messages
7
Programming Experience
1-3
i am having trouble doing a delete from with a dataadaper. i am able to update just fine.

i have two routines, one doing updates on a button press and another doing deletes on a button press

here is the update
VB.NET:
BindingSource1.EndEdit()
        Dim con As New OleDb.OleDbConnection(conString)
        Dim updateCmd As New OleDb.OleDbCommand("Update dept set description = '" & DescriptionTextBox.Text & "' where dept = '" & strOldDept & "' and cocodeid = 4", con)
        da.UpdateCommand = updateCmd
        da.Update(table)
        da.UpdateCommand = Nothing

and here is the delete

VB.NET:
 BindingSource1.EndEdit()
        Dim con As New OleDb.OleDbConnection(conString)
        Dim Cmd As New OleDb.OleDbCommand("delete  from dept where dept = '" & DeptTextBox.Text & "' and cocodeid = 4", con)
        da.DeleteCommand = Cmd
        da.Update(table)



for whatever reason the delete never goes through unless i click the delete button and then the update button to update a different record. anyone else have problems with deletes?
 
See the DW2 link in my signature, section on "Creating a SImple Data App" for advice on how you should be doing data access in .Net 2
 

Latest posts

Back
Top