2011-09-20 45 views
0

我需要根據錯誤代碼範圍區分sybase異常類型。區分Sybase異常類型

基本上我需要區分sybase系統相關的異常和數據異常。

我有用於處理sybase數據庫異常的c#代碼。

我們在異常中得到錯誤代碼,但我不知道定義錯誤代碼是sybase系統異常而不是數據異常的範圍。

我需要以不同的方式處理這兩個異常。

有人可以幫助這個。

複製下面的代碼。

using System.Data.Common; 

int Range1 = 0; 
int Range2 = 2000; 
try 
{ 
    // Sybase data base operation 
} 
catch (DbException e) 
      { 
    // Sybase system exception like database space not availabe , Time out error 
       if(e.ErrorCode > Range1 && e.ErrorCode< Range2) 
       { 
        // This is system excpetion so dump the data to be reprocessed after database is up . 
       } 
       // Excpetions like referential integrity violation , value is more than max length 
       else 
       { 
        // This is data releted exception so Don't process this data again as the data itself is wrong 
       } 
} 

回答

0

由於Sybase使用錯誤的數字小於2000年,我們選擇使用比3000更大的數字,您可以通過使用RAISERROR函數控制返回的錯誤代碼。是的,這不是拼寫錯誤。

注意:Sybase的許多功能都嘗試通過消除重複字符來節省擊鍵次數。在這種情況下,Sybase不允許使用雙「e」,但保留了雙「r」。

良好的SQL,晚安。