无法在 ADO OLEDB 中捕获 CommitTrans 当它给出0xc0000005错误时
can't trap CommitTrans in ADO OLEDB when it gives 0xc0000005 error
当我尝试执行CommitTrans时,当异常代码0xc0000005发生时,'catch'不会捕获:
_ConnectionPtr connection = NULL;
CoInitialize(NULL);
connection.CreateInstance(__uuidof(Connection));
connection->CursorLocation = adUseClient;
connection->Open(sConnectionString,L"",L"",0);
connection->Execute(sSQL,NULL,adCmdText);
try
{
connection->CommitTrans(); // <- 0xc0000005 1. Why? 2. 'catch' doens't trap
}
catch(...)
{
DWORD dwErr;
dwErr;
}
recordset->Close();
recordset = NULL;
connection->Close();
connection=NULL;
CoUninitialize();
- 为什么CommitTrans在这里失败了?
- 为什么"catch"不捕获失败?
要捕获0xc0000005异常,您需要使用结构化异常处理。
详情见此处
Try the following code and you will see that the program print "__except" rather than "catch".
#include <windows.h>
#include <iostream>
void foo()
{
try
{
int *p = NULL;
*p = 1;
}
catch ( ... )
{
std::cout << "catchn";
}
}
void bar()
{
__try
{
foo();
}
__except ( EXCEPTION_EXECUTE_HANDLER )
{
std::cout << "__exceptn";
}
}
int _tmain(int argc, _TCHAR* argv[])
{
bar();
std::cout << "successn";
return 0;
}
相关文章:
- 0xC0000005:访问冲突写入位置0xCDCDCDCD动态分配错误
- 进程返回 -1073741819 (0xC0000005) 错误
- C++ rezing 动态数组最多可以处理一定数量的元素,但在某些时候会崩溃并显示错误 (0XC0000005)
- OPENCV.3.0错误:0xc0000005:访问违规读取位置0x00000000
- 如何修复数据库连接的C 程序运行时间错误(0xc0000005)
- 多线程动画0xC0000005错误
- 什么是错误 (0xC0000005) 以及如何修复它
- Visual Studio C++ 0xC0000005错误:对内存分配感到困惑
- C 错误:0xc0000005:访问违规写作位置0xfeeefeee
- C++数组错误:访问冲突读取位置0xC0000005
- 运行时错误0xC0000005 - 访问冲突
- 错误 linkedlist .exe 中0x00D0345E处的未处理异常: 0xC0000005:访问违规写入位置0x
- C++随机0xC0000005错误
- 我收到此错误"Unhandled exception at 0x009437bd in Hash functions.exe: 0xC0000005: Access violation reading
- JRE检测到致命错误- EXCEPTION_ACCESS_VIOLATION (0xc0000005)
- 无法在 ADO OLEDB 中捕获 CommitTrans 当它给出0xc0000005错误时
- C++,错误,本机"已退出,代码为 -1073741819 (0xc0000005)
- 从C#调用非托管C++库(dll)会产生访问冲突错误(0xc0000005)
- Visual Studio 2012 错误 0xC0000005 数组输出
- VS2013错误0xC0000005:当使用libcurl