Database not commiting changes..

alander

Well-known member
Joined
Jun 26, 2007
Messages
120
Location
Singapore
Programming Experience
5-10
Hi again.. my database for some reason is not committing changes.. I do not know why either..

The problem only lies with 2 tables, all other updates fine.. and i seriously cant find the reason why, i checked my access database for referential integrity, but i dun see any problem cos its the same as how i defined the other tables..

here is my code


i am using checkbox control..

It commits when i use a datagridview but not when i uses a checkbox control..
VB.NET:
        If noError AndAlso (Me.DsEmployee.HasChanges) Then

            Me.Employee_ChildTableAdapter.Update(Me.DsEmployee.Employee_Child)
            Me.Employee_Education_HistoryTableAdapter.Update(Me.DsEmployee.Employee_Education_History)
            Me.Employee_WarningsTableAdapter.Update(Me.DsEmployee.Employee_Warnings)
            Me.EmployeeContactInfoAndRemarksTableAdapter.Update(Me.DsEmployee.EmployeeContactInfoAndRemarks)
            Me.EmployeePayRollTableAdapter.Update(Me.DsEmployee.EmployeePayRoll)
            Me.Employee_Working_ExperienceTableAdapter.Update(Me.DsEmployee.Employee_Working_Experience)
            Me.EmployeesInfoTableAdapter.Update(Me.DsEmployee.EmployeesInfo)
            Me.Employee_Family_DataTableAdapter.Update(Me.DsEmployee.Employee_Family_Data)'not commiting (combo box control)

            Me.Employee_Other_InfoTableAdapter.Update(Me.DsEmployee.Employee_Other_Info) 'not commiting (checkbox control)
            Me.DsEmployee.AcceptChanges()
            MessageBox.Show("Changes has been saved", "Saved", MessageBoxButtons.OK, MessageBoxIcon.Information)

        Else
            DsEmployee.RejectChanges()
            cmEmployee.Position = -1
        End If
        enableButtons()
        disableInputs()

the checkbox control uses checkedState binded to the dataset..
i tried checked, and it doesnt work either


can anyone point it out to me what is wrong? :confused:
 
Does the Me.DsEmployee.AcceptChanges() line return a value to indicate success?
Your error checking seems to check at the start of the if but not again after the acceptchanges.
Nort sure, but I would check for error after the acceptchanges line

Good Luck :)
 
Do you really use all those tables on one form? You dont need to update every table in your dataset, just the ones you have edited.

You also dont need to call AcceptChanges - the tableadapters will do that for you.

Show more info on how you bind your column to the checkbox, and what type and info is already in the column
 
it is not binded to the checkbox on the datagrid view, it is directly binded to the checkbox (on windows form control).. i dun have a problem with the checkbox in datagrid view..
 
Last edited:
i did some checks and i found out my dataset couldnt detect the changes in my child table..

attached images

my dataset
4ubs9yq.jpg


my form b4 change
4zk00tu.jpg


my form after typing test test and clicking on save..
6gaiurd.jpg


My binding source is binded to
EmployeesInfoBindingSource

my bindsource data member is
EmployeesInfo_EmployeeContactInfoAndRemarks

my code for this part
VB.NET:
if dsEmployee.hasChanges then
  Me.EmployeeContactInfoAndRemarksTableAdapter.Update
(Me.DsEmployee.EmployeeContactInfoAndRemarks)

else

MessageBox.Show("No Change Was detected", "No Change", MessageBoxButtons.OK, MessageBoxIcon.Information)

end if

Did i bind wrongly?
 
It would have been more helpful to see the design of the form, but i'll make a guess

The form on display has a top part, and several bottom parts. I presume that the top part is the parent record Employee
The bottom part on show, contact info is a child table EmployeeContactInfo...

So your save process would look something like this:

VB.NET:
Me.Validate()
EmployeeBindingSource.EndEdit()
EmployeeContactInfoBindingSource.EndEdit()
EmployeeTableAdapter.Update(dataset)
EmployeeContactInfoTableAdapter(dataset)
 
oo.. i missed out end edit and validate..

ty..
 
Back
Top