Click here to Skip to main content
16,019,764 members
Please Sign up or sign in to vote.
3.40/5 (2 votes)
See more:
How to check whether a update query updated the record or not. i have used cmd.ExecuteNonQuery() to update record
Posted
Comments
Madhav Hatwalne 17-Jun-13 6:12am    
Every fresher must know how to achieve this!

In Store Procedure

SQL
BEGIN TRY 
BEGIN TARN
your code
COMMIT TRAN
Select 1 As 'Sucess'
END TRY
BEGIN CATCH
ROLLBACK TRAN
SELECT 0 AS 'Error'
END CATCH


In C# Code

You can refer to this link

http://stackoverflow.com/questions/1249091/how-to-get-datatable-as-a-result-of-stored-procedure[^]
 
Share this answer
 
For such cases My method is set try and catch block if Transaction is successful use Select 1 and in front end get output in 1 dataset and check dataset element is true or false on that basis you can check transaction completed or not
 
Share this answer
 
Comments
Usha Muhunthan 17-Jun-13 2:01am    
Thank u Madhav Hatwalne.
If cmd.ExecuteNonQuery()=true Then
IS this one Correct
Madhav Hatwalne 17-Jun-13 5:50am    
No not like this!
Usha Muhunthan 21-Jun-13 1:50am    
I checked If cmd.ExecuteNonQuery()=true is correct one
Madhav Hatwalne 24-Jun-13 1:36am    
Get your result of procedure in a dataset and check the the first element of the first row
u have to use Datadapter

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