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

📄 oracletestdlg.cpp

📁 rar内附有详细的步骤说明
💻 CPP
字号:
// OracleTestDlg.cpp : implementation file
//

#include "stdafx.h"
#include "OracleTest.h"
#include "OracleTestDlg.h"

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

/////////////////////////////////////////////////////////////////////////////

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();
	
	// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA
	
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL
	
	// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// COracleTestDlg dialog

COracleTestDlg::COracleTestDlg(CWnd* pParent /*=NULL*/)
: CDialog(COracleTestDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(COracleTestDlg)
	m_DatabaseName = _T("111");
	m_LogonName = _T("system");
	m_LogonPassWord = _T("manager");
	m_SQL = _T("insert into sly.testoracle values('24455','22343434')");
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void COracleTestDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(COracleTestDlg)
	DDX_Text(pDX, IDC_EDIT1, m_DatabaseName);
	DDX_Text(pDX, IDC_EDIT2, m_LogonName);
	DDX_Text(pDX, IDC_EDIT3, m_LogonPassWord);
	DDX_Text(pDX, IDC_EDIT_SQL, m_SQL);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(COracleTestDlg, CDialog)
//{{AFX_MSG_MAP(COracleTestDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_CONNECTION, OnConnection)
	ON_BN_CLICKED(IDC_DISCONNECT, OnDisconnect)
	ON_EN_CHANGE(IDC_EDIT_SQL, OnChangeEditSql)
	ON_BN_CLICKED(IDC_GoSQL, OnGoSQL)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// COracleTestDlg message handlers

BOOL COracleTestDlg::OnInitDialog()
{
	CDialog::OnInitDialog();
	
	// Add "About..." menu item to system menu.
	
	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);
	
	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}
	
	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void COracleTestDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void COracleTestDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting
		
		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
		
		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;
		
		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR COracleTestDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void COracleTestDlg::OnConnection() 
{
	
	double sum=0.0; // sum of all salaries
	
//	double cursal; // salary of the current employee
	UpdateData();
	// connect to the database
	try
	{

		orocldb.Open(m_DatabaseName, m_LogonName,m_LogonPassWord);
		if(!orocldb.IsOpen())
		{
			const char *m_errortext=orocldb.GetErrorText();
			MessageBox(m_errortext,"错误",MB_OK|MB_ICONERROR);		
			return ;
		}else
			MessageBox("连接oracle成功!");
		
		orocldb.SetAutoCommit(true);
		//oresult rrr = orocldb.BeginTrans();
		CString strsql="INSERT INTO CO.T_UPLOADLOG(\
			upl_id,upl_vicid,upl_uploadtype,upl_uploaduser,\
			upl_savename,upl_uploadtime,\
			upl_filelength,upl_filepath,upl_discription,upl_savetime,\
			upl_isdescomp,upl_isfinished) \
			VALUES(\
			BAKID.NEXTVAL,1010,'BACKUP','XXX',\
			'Sb_62010171902306X_20030731.rar',\
			to_date('2004-09-21 08:00:00','YYYY-MM-DD HH24:MI:SS')\
			,100,'BACKUP\\Sb_62010171902306X_20030731.rar',\
			'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',365,0,0);";
		orocldb.ExecuteSQL(strsql);
		orocldb.ExecuteSQL("commit");
		
/*		dyn.Open(orocldb, this->m_SQL);
		if (!dyn.IsOpen())
			return; // can’t open dynaset
		CString salary, raise;
		// go through all the records 
		while (!dyn.IsEOF())
		{ // for every record
			const char* ov;
			OValue re;
			const char*en="id";
			dyn.GetFieldValue(en, &re); // get old salary
			ov =  (const char*)re ; 
			CString  str=ov;
			//str.Format()
			AfxMessageBox(str+"Get the Value\r\n");
		/*	if (dyn.AddNewRecord() != OSUCCESS)
			{
				AfxMessageBox(str+"Before Update\r\n");
				return ;
			}
			dyn.MoveNext(); // go to the next record
			en="23";
			dyn.SetFieldValue("id", en);
			dyn.SetFieldValue("Name",en);
			dyn.Update();*/
/*			dyn.MoveNext(); // go to the next record
		}
		dyn.Close();
*/	}catch(OException *e)
	{
		
		CString str;
		str=e->GetErrorText();
		AfxMessageBox(str,0,NULL);
		//	e->Cleanup();
		
	}
	
	
	
}

void COracleTestDlg::OnDisconnect() 
{
	// TODO: Add your control notification handler code here
	orocldb.Close();
}

void COracleTestDlg::OnChangeEditSql() 
{
	
	// TODO: Add your control notification handler code here
	
}

void COracleTestDlg::OnGoSQL() 
{
	UpdateData();
	if (orocldb.IsOpen())
	{
		orocldb.SetAutoCommit(true);
		oresult rrr = orocldb.BeginTrans();
		orocldb.ExecuteSQL(this->m_SQL);
		rrr= orocldb.CommitTrans();
	
	}else
	{
		MessageBox("数据库连接没有开启","错误",64);
	}
	
}

⌨️ 快捷键说明

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