⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unrecoverablemfcexception.cpp

📁 vc ADO 连接数据库
💻 CPP
字号:
// UnrecoverableMFCException.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "UnrecoverableMFCException.h"
#include "msado15.h"

struct InitOle {
InitOle()  { ::CoInitialize(NULL); }
~InitOle() { ::CoUninitialize();   }
} _init_InitOle_;


#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CUnrecoverableMFCExceptionApp

BEGIN_MESSAGE_MAP(CUnrecoverableMFCExceptionApp, CWinApp)
	//{{AFX_MSG_MAP(CUnrecoverableMFCExceptionApp)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG
	ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CUnrecoverableMFCExceptionApp construction

CUnrecoverableMFCExceptionApp::CUnrecoverableMFCExceptionApp()
{
	// TODO: add construction code here,
	// Place all significant initialization in InitInstance
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CUnrecoverableMFCExceptionApp object

CUnrecoverableMFCExceptionApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CUnrecoverableMFCExceptionApp initialization

BOOL CUnrecoverableMFCExceptionApp::InitInstance()
{
_Connection     Conn1;
_Recordset      Rs1;

VARIANT         vRecords;
COleException   e;

try
{
  // Commenting out this line generates the exception
//      Conn1.CreateDispatch( "ADODB.Connection.2.0", &e );
    Conn1.Open( "", "", "", -1 );
    VariantInit( &vRecords );
    Rs1 = Conn1.Execute( "SELECT * FROM Authors", &vRecords, 1 );
}
catch( ... )
{
    TRACE( "The Catch Block that will never catch this exception is here\n" );
}

	// Since the dialog has been closed, return FALSE so that we exit the
	//  application, rather than start the application's message pump.
	return FALSE;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -