Click here to Skip to main content
15,889,745 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I'm developing a system tat will ask the user to enter his information then this information will be stored in database in access file. i've wrote this code and when I run it it doesn't give any error message but the data don't store in the access file.

C++
On Error GoTo saveErr
        Your_profileBindingSource.EndEdit()
        Your_profileTableAdapter.Update(Database1DataSet3.your_profile)
        MessageBox.Show("Done")
saveErr:
        Exit Sub


What I have tried:

i tried debugging but as i see there is no wrong with my code
Posted
Updated 22-Apr-18 23:03pm

It doesn't give an error because you are specifically telling it to ignore all errors, that's what On Error does - when an error occurs, you transfer control directly to the the label and exit the function, effectively ignoring the error.

And BTW:
Quote:
i see there is no wrong with my code
A lack of Compiler errors does not mean your code works. All that means is that you have written it in the right language (think of an email - you wrote it in English words, not German) not that it does what you wanted it to (that email - does it invite your friends to a party, or tell them to go jump off a cliff? Both are English, so they "compile" but only one of them will work).

Remove your On Error or handle the error so you can report / log it, and use the debugger to find out exactly what is happening when you code runs.
 
Share this answer
 
If you use a BindingSource[^], you have to call ResetBindings Method[^] to update binded controls. See: How to: Reflect Data Source Updates in a Windows Forms Control with the BindingSource | Microsoft Docs[^]

I'd recommend to use Try ... Catch... End Try code block to handle errors on updating data. See: Update data by using a TableAdapter[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900