- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我需要捕获以下特定异常:
System.Data.OleDb.OleDbException was caught ErrorCode=-2147467259
Message="The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again." Source="Microsoft JET Database Engine" StackTrace: at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr) at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
我不确定 ErrorCode
是什么,但它看起来不可靠。
我可以相信 Message
在不同平台上是相同的吗?
我能否以某种方式使用在堆栈跟踪中找到的 OleDbHResult hr
值? (参见 https://stackoverflow.com/a/991660/327528)
对 Message
进行文本搜索以查找 duplicate
和 primary key
之类的词的唯一解决方案是什么?
最佳答案
您是对的,ErrorCode (-2147467259 = 0x80004005 = E_FAIL) 太笼统了,依赖消息非常脆弱 - 例如考虑本地化。
我会查看 OleDbException.Errors
集合以尝试找到更具体的内容。
关于.net - 如何捕获特定的 OleDbException?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12796934/
我需要捕获以下特定异常: System.Data.OleDb.OleDbException was caught ErrorCode=-2147467259 Message="The changes
如果我犯了错误,我似乎无法理解。 OleDbCommand command = new OleDbCommand(); command.Connection = con
我构建了一个 c# 应用程序,您可以在其中登录并注册一个新帐户。但是当我点击我的新帐户按钮并填写必填字段时,我会收到以下错误: vcom.ExecuteNonQuery(); -> OleDBExce
以下代码执行一个简单的插入命令。如果连续调用 2,000 次(插入 2,000 行),则会抛出消息为“已超出系统资源”的 OleDbException。我还应该做些什么来释放资源吗? using (O
我有以下代码来验证 MSAccess 2003 数据库是否被另一个应用程序以独占模式打开(数据库已经有密码): OleDbConnectionStringBuilder conString = new
我有以下代码(Windows 窗体的一部分)在我的机器上成功连接到 Excel 文件,但在不同的机器上却失败了。 var fd = new OpenFileDialog(); if (fd.ShowD
我在测试如何通过选择所需的列然后指定唯一 ID(即按主 ID、ID 排序的房间号)来获取最新的数据库条目时遇到此错误。 这是我的代码: Private Sub Form5_Load(ByVal s
我在测试如何通过选择所需的列然后指定唯一 ID(即按主 ID、ID 排序的房间号)来获取最新的数据库条目时遇到此错误。 这是我的代码: Private Sub Form5_Load(ByVal s
我在调试程序的时候发现了这个问题: System.Data.dll 中发生类型为“System.Data.OleDb.OleDbException”的未处理异常 附加信息:UPDATE 语句中的语法错
我正在使用以下代码更新 Excel 文件中的单元格。 public bool WriteChange(string Filename, string SheetName, string Cell, s
我有一个 excel 文件和一个 oledb 连接。在 Windows 中打开文件时读取数据时,会抛出以下错误(在 Adapter.Fill 方法处)。 但是,当文件未手动打开时,代码运行正常。 pr
尝试在我的 D 盘 (D:\TaalTipsDocumenten) 上的文件夹中搜索索引文件时出现异常(OleDBException:未指定错误)。我知道这段代码在过去(2 个月前)有效,但当我试图继
我创建了一个按钮 (Next) 以在名为 CHAPTERS 的表中导航; 我的问题是按钮工作了两次,有时是三次。之后我得到 [Not specified error]。 这是我的代码: Dim S A
我尝试编写代码来 Access 数据库,但在粗体字行出现 OldDbException 错误。我应该如何更改我的话,以便在运行时不会出现任何错误? private void submitbut
目录 可能解决方法1 可能解决方法2 可能解决办法3 可能解决办法4 异常详细信息: System.Data.OleDb.OleDbExcept
我在调试时遇到错误,请有人帮忙...下面是代码: Private Sub UpdateToolStripMenuItem_Click(ByVal sender As System.Object, B
我使用 Visual Studio Enterprise 2015 WPF 来完成我的项目,我的数据库是一个 ms access 文件我不确定为什么会出现此错误有人可以 System.Data.dll
您好,我是 C# 的新手,正在尝试连接到 .accdb access 2010 数据库 using System; using System.Collections.Generic; using Sy
我有一个 VB.Net 程序,它读取一个平面文件,然后逐行解析,将数据格式化为 excel 工作簿中的不同电子表格(每行可以是任何 10 多种不同的记录类型,所以我解析并放入适当的 excel床单)。
我是编程新手,我在 VB.net 中编写的 Web 应用程序有问题。我的项目中有一个 Access 数据库,并且正在使用参数化查询从中检索信息。奇怪的是,我在另一个工作正常的页面上使用了几乎相同的查询
我是一名优秀的程序员,十分优秀!