c#Dot网络中主键的异常 [英] Exception for primary key in c#Dot net

查看:81
本文介绍了c#Dot网络中主键的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

c#Dot net中主键的异常类

Exception class for primary key in c#Dot net

推荐答案

您的问题不是很清楚.我仍然假设您要测试主键异常.

检查此链接..

如何测试主键异常 [ ^ ]

如何捕获主键异常 [ ^ ]
your question is not very clear. still i assume that you want to test primary key exception.

check this link..

how test primary key exception[^]

how to catch primary key exception[^]


您可以捕获异常
You can catch the exception
atch(System.Data.SqlClient.SqlException ex)
{
    if(ex.Number==2627) { /* special case for primary key violation */ }
    else throw;   // rethrows without affecting the stack trace
    // else throw ex; // rethrows with the stack trace reset to this line
}


这篇关于c#Dot网络中主键的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆