现在的位置: 首页 > 综合 > 正文

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

2011年01月30日 ⁄ 综合 ⁄ 共 454字 ⁄ 字号 评论关闭
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;
                }

            }

抱歉!评论已关闭.