I have a customer table in sqlserver which contains a rowversion field and I am incrementing it everytime I update the record,
I just have to check with
if(Customer.rowversion=@roeversion ) where customerID=@customerID
execute the update.
else RAISERROR('Update cannot be executed. There is a row version conflict.', 16, 1)
So have to now pass an out param from my c# code and return the error value. and also
– Get the Error Code for the statement just executed.
SELECT @ErrorCode=@@ERROR
So how should I return the value from SQLSERVER update query into my c# code so that I can display the message.
If you do not already, you should have your database code in a stored procedure. The stored procedure would look something like:
You should try to avoid raising errors whenever possible.
Then, assuming you have a stored procedure executed by a command: