Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
To prevent duplicate data input by user on grid, I changed a column in dataset to unique. And whenever the same data is input, an error show up.
Error
"Column 'ColName' is constrained to be unique. Value 'Value' is already present. Do you want to correct the value?"

There are two button in the error box, yes and no.
If I press yes then I was forced to edit the value to valid one.
If no then the row deleted.

I need to replace the box with a simple messagebox and delete the invalid row, but I don't know where to catch the exception since it's not came from my code.
Posted
Comments
[no name] 23-Aug-14 11:20am    
You can certainly catch SQL exceptions in your code.
Midnight Ahri 23-Aug-14 11:26am    
Yes, but I want to catch it before save.
When I input the same existing data, the error occur.
I'm using binding.
[no name] 23-Aug-14 11:42am    
Okay.... and? Validate the data before the save then. Don't allow the user to change the data to begin with.
[no name] 27-Aug-14 2:09am    
where is ur code

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