Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
ExecuteSQLProc.cpp
Package: ISQL_src.zip [view]
Upload User: jsxglz
Upload Date: 2007-01-03
Package Size: 117k
Code Size: 2k
Category:
SQL Server
Development Platform:
Visual C++
- // ExecuteSQLProc.cpp: implementation of the CExecuteSQLProc class.
- //
- #include "stdafx.h"
- #include "interactivesql.h"
- #include "ExecuteSQLProc.h"
- #include "ResultView.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- const char* g_szFunctionSequenceError = "State:S1010";
- //////////////////////////////////////////////////////////////////////
- // CExecuteSQLProc
- CExecuteSQLProc::CExecuteSQLProc()
- {
- }
- CExecuteSQLProc::~CExecuteSQLProc()
- {
- }
- UINT ExecuteSQLProc(LPVOID lpVoid)
- {
- ThreadParam* pTP = (ThreadParam*)lpVoid;
- ASSERT(pTP);
- ASSERT(!pTP->m_strSQL.IsEmpty());
- CMainFrame* pFrame = pTP->m_pFrame;
- ASSERT(pFrame);
- ASSERT(pTP->m_pView);
- ASSERT(pTP->m_pFrame->m_pSet);
- BOOL bCaughtException = FALSE;
- try
- {
- if(pTP->m_pFrame->m_pSet->m_hstmt && pTP->m_pFrame->m_pSet->IsOpen())
- pTP->m_pFrame->m_pSet->Close();
- pTP->m_pFrame->m_database.SetQueryTimeout(pTP->m_pFrame->m_nQueryTimeOut);
- pTP->m_pFrame->m_pSet->ExecDirect(pTP->m_strSQL);
- }
- catch(CDBException* e)
- {
- bCaughtException = TRUE;
- if(e)
- {
- CString sMsg;
- if(e->m_strStateNativeOrigin.Find(g_szFunctionSequenceError) != -1)
- {
- pTP->m_pFrame->m_bCanceled = TRUE;
- sMsg = "Query canceled by user.";
- pTP->m_pFrame->m_strStatusText = "Canceled";
- }
- else
- {
- if(!e->m_strError.IsEmpty())
- sMsg.Format("%s%s", (LPCTSTR)e->m_strError, (LPCTSTR)e->m_strStateNativeOrigin);
- else
- sMsg = e->m_strStateNativeOrigin;
- pTP->m_pFrame->m_strStatusText.Format("CDBException::m_nRetCode == %d", e->m_nRetCode);
- }
- pTP->m_pView->SetWindowText(sMsg);
- e->Delete();
- }
- }
- catch(CMemoryException* e)
- {
- bCaughtException = TRUE;
- pTP->m_pFrame->m_strStatusText = "Out-of-memory";
- pTP->m_pView->SetWindowText(pTP->m_pFrame->m_strStatusText);
- if(e)
- e->Delete();
- }
- if(bCaughtException)
- if(pTP->m_pFrame->m_pSet->IsOpen())
- pTP->m_pFrame->m_pSet->Close();
- ::PostMessage(pTP->m_pFrame->m_hWnd, WM_EXECUTION_COMPLETE, bCaughtException, 0L);
- return 0; // Gracefully exit
- }