ASP.NET 动态数据中的异常

发布于 2024-08-09 02:43:52 字数 136 浏览 6 评论 0原文

我有一个 ASP.NET 动态数据应用程序(使用实体框架),在尝试数据库插入时我刚刚发现重复键错误。但是,我必须使用 SQL Profiler 来查找错误。插入模板页面只是默默地什么也没做。

我如何捕获这样的错误并记录它们并可能显示一条消息?

I have an ASP.NET Dynamic Data application (using Entity Framework) in which I have just discovered a duplicate key error when attempting a database insert. However, I had to use SQL Profiler to find the error. The insert template page just silently did nothing.

How can I trap errors like this and log them and maybe display a message?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

顾冷 2024-08-16 02:43:52

如果未捕获,则可以在 DetailsView 和 DataSource 控件上的 CUD 事件参数中检测到异常,例如 DetailsView_ItemInsertedDetailsDataSource_Inserting 等事件具有 Exception 异常bool ExceptionHandled 属性用于处理异常。

Exceptions can be detected, if not caught, in the CUD event arguments on the DetailsView and the DataSource controls, e.g. events such as DetailsView_ItemInserted, and DetailsDataSource_Inserting have Exception Exception and bool ExceptionHandled properties for handling exceptions.

木格 2024-08-16 02:43:52

您可以在动态数据站点中实现的另一种方法是使用自定义派生的 DynamicValidator 控件。

有关详细信息,请参阅链接 处理动态数据中的数据库异常

Another approach that you could implement in Dynamic Data site is using a custom derived DynamicValidator control.

For detail information, please, refer to the link Handling database exceptions in Dynamic Data

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文