how to handle error ??

Posted by Paraszalariya12 under C# on 6/27/2013 | Points: 10 | Views : 471 | Status : [Member] | Replies : 2
i have three table and i inserted data in that table.
i inserted data in two table successfully but in the third table i getting error.
so i want to do when i am getting error on inserting time further table which one inserted successfully that will be rollback the data.
so what i should have to use ?? i don't know related this topic plz help me ......:-)




Responses

Posted by: Niladri.Biswas on: 6/27/2013 [Member] Platinum | Points: 25

Up
0
Down
Database Transaction is the topic name

Best Regards,
Niladri Biswas

Paraszalariya12, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: perfectchourasia-9163 on: 6/27/2013 [Member] Starter | Points: 25

Up
0
Down
USE AdventureWorks;
GO
BEGIN TRY
-- Generate a divide-by-zero error.
Write Insert Command here
END TRY
BEGIN CATCH
SELECT
ERROR_NUMBER() AS ErrorNumber,
ERROR_SEVERITY() AS ErrorSeverity,
ERROR_STATE() AS ErrorState,
ERROR_PROCEDURE() AS ErrorProcedure,
ERROR_LINE() AS ErrorLine,
ERROR_MESSAGE() AS ErrorMessage;
END CATCH;
GO

ER sandeep chourasia
sandeepchrs@yahoo.com (on facebook)
http://www.aspnetcodes.com/

Paraszalariya12, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response