SQL Server Raiserror not causing exception in .NET client

后端 未结 4 1313
说谎
说谎 2021-01-13 07:19

I have a stored procedure on a SQL Server 2005 database which has a statement like this:

  IF @Condition = 0
    BEGIN
        RAISERROR(\'some error message         


        
4条回答
  •  有刺的猬
    2021-01-13 07:57

    I went through the SQL Helper class and found out that ExecuteScalar eats the exception and returns null. I switched to ExecuteDataSet which doesn't do this. I expected the different Execute.. method to behave the same way. The other way is to use ExecuteScalar and when the SP detects an error, it does a SELECT some error number which can be handled in the client.

提交回复
热议问题