荷子青

荷子青

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

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;
                }

            }

posted on 2005-11-25 15:20  荷子青  阅读(1451)  评论(0编辑  收藏  举报

导航