문제

I'm writing a small app that will be used to deploy stored procedure updates/releases across a number of servers.

I need to report back that the update on each server was successful.

At present I'm simply doing the following:

int response =  server.ConnectionContext.ExecuteNonQuery(sql);

This successfully updates the sp, but the response is always a random minus number (-3, -4 etc).

What would be the best way to get a response to report back if each update was successful or not?

도움이 되었습니까?

해결책

What would be the best way to get a response to report back if each update was successful or not

if the query has executed successfully and you haven't caught any exception then it means it is a success. otherwise it failed.

다른 팁

You can implement Transaction (if your sql command based on multiple table) along with Try-Catch in SQL by using RAISERROR. You get get the error as output variable.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top