学会了怎么样利用捕获异常提示数据库主键重复错误

try
            
{
                
int re=SqlHelper.ExecuteNonQuery(SysConfiguration.ConnectionString, CommandType.StoredProcedure, "upd_task_complete_month",arParms); 
                
return re;
            }

            
catch (SqlException ex)
            
{
                
if(ex.Number==2627)
                
{
                    
return -1;  //主键重复
                }

                
else
                
{
                    
return 0;
                }

            }

你可能感兴趣的:(数据库)