📄 stdafx.h
字号:
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#if !defined(AFX_STDAFX_H__4D954AB8_AFCC_4375_9BF5_B7796280135E__INCLUDED_)
#define AFX_STDAFX_H__4D954AB8_AFCC_4375_9BF5_B7796280135E__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// Insert your headers here
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
//#include <windows.h>
//
// MODULE: Ado.h
//
// AUTHOR: Carlos Antollini
//
// mailto: cantollini@hotmail.com
//
// Date: 07/25/2002
//
// Version 2.04
//
#ifndef _ADO_H_
#define _ADO_H_
/*
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
*/
#include <afx.h>
#include <afxdisp.h>
#include <math.h>
#pragma warning (disable: 4146)
// CG : In order to use this code against a different version of ADO, the appropriate
// ADO library needs to be used in the #import statement
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" rename_namespace("ADOCG") rename("EOF", "EndOfFile")
using namespace ADOCG;
#pragma warning (default: 4146)
#include "icrsint.h"
class CADOCommand;
struct CADOFieldInfo
{
char m_strName[30];
short m_nType;
long m_lSize;
long m_lDefinedSize;
long m_lAttributes;
short m_nOrdinalPosition;
BOOL m_bRequired;
BOOL m_bAllowZeroLength;
long m_lCollatingOrder;
};
CString IntToStr(int nVal);
CString LongToStr(long lVal);
CString ULongToStr(unsigned long ulVal);
CString DblToStr(double dblVal, int ndigits = 20);
CString DblToStr(float fltVal);
class CADODatabase
{
public:
CADODatabase()
{
::CoInitialize(NULL);
m_pConnection = NULL;
m_strConnection = _T("");
m_strLastError = _T("");
m_dwLastError = 0;
m_pConnection.CreateInstance(__uuidof(Connection));
m_nRecordsAffected = 0;
}
~CADODatabase()
{
Close();
m_pConnection.Release();
m_pConnection = NULL;
m_strConnection = _T("");
m_strLastError = _T("");
m_dwLastError = 0;
::CoUninitialize();
}
BOOL Open(LPCTSTR lpstrConnection = _T(""), LPCTSTR lpstrUserID = _T(""), LPCTSTR lpstrPassword = _T(""));
_ConnectionPtr GetActiveConnection()
{return m_pConnection;};
BOOL Execute(LPCTSTR lpstrExec);
int GetRecordsAffected()
{return m_nRecordsAffected;};
DWORD GetRecordCount(_RecordsetPtr m_pRs);
long BeginTransaction()
{return m_pConnection->BeginTrans();};
long CommitTransaction()
{return m_pConnection->CommitTrans();};
long RollbackTransaction()
{return m_pConnection->RollbackTrans();};
BOOL IsOpen();
void Close();
void SetConnectionString(LPCTSTR lpstrConnection)
{m_strConnection = lpstrConnection;};
CString GetConnectionString()
{return m_strConnection;};
CString GetLastErrorString()
{return m_strLastError;};
DWORD GetLastError()
{return m_dwLastError;};
protected:
void dump_com_error(_com_error &e);
public:
_ConnectionPtr m_pConnection;
protected:
CString m_strConnection;
CString m_strLastError;
DWORD m_dwLastError;
int m_nRecordsAffected;
};
class CADORecordset
{
public:
BOOL Clone(CADORecordset& pRs);
enum cadoOpenEnum
{
openUnknown = 0,
openQuery = 1,
openTable = 2,
openStoredProc = 3
};
enum cadoEditEnum
{
dbEditNone = 0,
dbEditNew = 1,
dbEdit = 2
};
enum cadoPositionEnum
{
positionUnknown = -1,
positionBOF = -2,
positionEOF = -3
};
enum cadoSearchEnum
{
searchForward = 1,
searchBackward = -1
};
enum cadoDataType
{
typeEmpty = adEmpty,
typeTinyInt = adTinyInt,
typeSmallInt = adSmallInt,
typeInteger = adInteger,
typeBigInt = adBigInt,
typeUnsignedTinyInt = adUnsignedTinyInt,
typeUnsignedSmallInt = adUnsignedSmallInt,
typeUnsignedInt = adUnsignedInt,
typeUnsignedBigInt = adUnsignedBigInt,
typeSingle = adSingle,
typeDouble = adDouble,
typeCurrency = adCurrency,
typeDecimal = adDecimal,
typeNumeric = adNumeric,
typeBoolean = adBoolean,
typeError = adError,
typeUserDefined = adUserDefined,
typeVariant = adVariant,
typeIDispatch = adIDispatch,
typeIUnknown = adIUnknown,
typeGUID = adGUID,
typeDate = adDate,
typeDBDate = adDBDate,
typeDBTime = adDBTime,
typeDBTimeStamp = adDBTimeStamp,
typeBSTR = adBSTR,
typeChar = adChar,
typeVarChar = adVarChar,
typeLongVarChar = adLongVarChar,
typeWChar = adWChar,
typeVarWChar = adVarWChar,
typeLongVarWChar = adLongVarWChar,
typeBinary = adBinary,
typeVarBinary = adVarBinary,
typeLongVarBinary = adLongVarBinary,
typeChapter = adChapter,
typeFileTime = adFileTime,
typePropVariant = adPropVariant,
typeVarNumeric = adVarNumeric,
typeArray = adVariant
};
BOOL SetFieldValue(int nIndex, int nValue);
BOOL SetFieldValue(LPCTSTR lpFieldName, int nValue);
BOOL SetFieldValue(int nIndex, long lValue);
BOOL SetFieldValue(LPCTSTR lpFieldName, long lValue);
BOOL SetFieldValue(int nIndex, unsigned long lValue);
BOOL SetFieldValue(LPCTSTR lpFieldName, unsigned long lValue);
BOOL SetFieldValue(int nIndex, double dblValue);
BOOL SetFieldValue(LPCTSTR lpFieldName, double dblValue);
BOOL SetFieldValue(int nIndex, CString strValue);
BOOL SetFieldValue(LPCTSTR lpFieldName, CString strValue);
BOOL SetFieldValue(int nIndex, COleDateTime time);
BOOL SetFieldValue(LPCTSTR lpFieldName, COleDateTime time);
BOOL SetFieldValue(int nIndex, bool bValue);
BOOL SetFieldValue(LPCTSTR lpFieldName, bool bValue);
BOOL SetFieldValue(int nIndex, COleCurrency cyValue);
BOOL SetFieldValue(LPCTSTR lpFieldName, COleCurrency cyValue);
BOOL SetFieldValue(int nIndex, _variant_t vtValue);
BOOL SetFieldValue(LPCTSTR lpFieldName, _variant_t vtValue);
BOOL SetFieldEmpty(int nIndex);
BOOL SetFieldEmpty(LPCTSTR lpFieldName);
void CancelUpdate();
BOOL Update();
void Edit();
BOOL AddNew();
BOOL AddNew(CADORecordBinding &pAdoRecordBinding);
BOOL Find(LPCTSTR lpFind, int nSearchDirection = CADORecordset::searchForward);
BOOL FindFirst(LPCTSTR lpFind);
BOOL FindNext();
CADORecordset()
{
m_pRecordset = NULL;
m_pCmd = NULL;
m_strQuery = _T("");
m_strLastError = _T("");
m_dwLastError = 0;
m_pRecBinding = NULL;
m_pRecordset.CreateInstance(__uuidof(Recordset));
m_pCmd.CreateInstance(__uuidof(Command));
m_nEditStatus = CADORecordset::dbEditNone;
m_nSearchDirection = CADORecordset::searchForward;
}
CADORecordset(CADODatabase* pAdoDatabase);
~CADORecordset()
{
Close();
if(m_pRecordset)
m_pRecordset.Release();
if(m_pCmd)
m_pCmd.Release();
m_pRecordset = NULL;
m_pCmd = NULL;
m_pRecBinding = NULL;
m_strQuery = _T("");
m_strLastError = _T("");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -