Database exception handling??
-
Say suppose I have developed a small application by vb.net, which will insert new record and modify existing record and delete existing record. At the time of inserting new record then primary key, index, unique key, check key can violate for reason like duplicate record, like null value. So how could I capture those errors separately and show proper message for different type of errors to user. At the time of deletion relation can violate say suppose user are trying to delete record from parent table where references are in the child table, at that time foreign key will violate and I want to capture that and show proper message to user. Please solve my problem giving me the proper exception handling code with comment implement by vb.net. tbhattacharjee
-
Say suppose I have developed a small application by vb.net, which will insert new record and modify existing record and delete existing record. At the time of inserting new record then primary key, index, unique key, check key can violate for reason like duplicate record, like null value. So how could I capture those errors separately and show proper message for different type of errors to user. At the time of deletion relation can violate say suppose user are trying to delete record from parent table where references are in the child table, at that time foreign key will violate and I want to capture that and show proper message to user. Please solve my problem giving me the proper exception handling code with comment implement by vb.net. tbhattacharjee
Since SQLServer is generating the errors, your SQL procedures can return codes to your VB.NET code so you can determine what to do with the errors there. But, if your code is written properly, your SQL database is setup and the stored procedures that do the actual work are written properly, you should never have to deal with foreign key violations like what your talking about. The only way a user can delete a record from a parent table and violate the child relations is if your code lets them do it in the first place. RageInTheMachine9532