📄 myadoclass.h
字号:
#pragma once
#import "C:\Program Files\Common Files\System\ado\msado15.dll" raw_interfaces_only no_namespace rename("EOF", "ADOEOF")
// CMyAdoClass 命令目标
class CMyAdoClass
{
public:
CMyAdoClass();
virtual ~CMyAdoClass();
private:
_CommandPtr m_command;
_RecordsetPtr m_recordset;
_ConnectionPtr m_connection;
public:
HRESULT hr;
bool ExecuteCommand(VARIANT_BOOL bStoredProcedure, VARIANT_BOOL bChangeRec);
bool Close(void);
bool CloseRecordset(void);
bool Delete(void);
bool ExecuteConnection(BSTR query, VARIANT_BOOL bChangeRec);
//使用SQL语句修改记录,例如:
//建立表:ExecuteConnection("CREATE TABLE HotBikes (ID INTEGER, Model VarChar(25), Manufacturer VarChar(80))", VARIANT_FALSE);
//插入记录:insert into HotBikes (ID, Model, Manufacturer) values (?, ?, ?)";
//修改记录:UPDATE HotBikes SET TopSpeed=170 WHERE ID=1
bool MoveFirst();
short get_BOF();
bool get_CommandText(BSTR * newVal);
short get_Empty();
short get_EOF();
bool get_Field(int FieldIndex,VARIANT *FieldValue);
bool get_FieldCount(long * newVal);
bool MoveLast();
bool MoveNext();
bool OpenRecordset(VARIANT query,bool isBatchUpdate);//获取记录集
bool put_CommandText(BSTR newVal);
bool put_Field(int idx, VARIANT newVal);
bool put_StoredProc(BSTR newVal);
bool ParamQuery(BSTR query, long idx1, BSTR idx2, BSTR idx3);//插入记录的例子
bool MovePrev();
bool Requery();
bool ChangeParameter(long idx, enum DataTypeEnum type, VARIANT value, enum ParameterDirectionEnum where, long size);
bool ADORelease();
bool Open(const WCHAR* ConnectStr, const WCHAR* UserName, const WCHAR* Password);
bool GetFieldsName(long *pFieldsCount,LPWSTR** ppFieldsNameArray);
bool GetFieldsValue(long *pFieldsCount,VARIANT** ppFieldsValue);
bool PutFieldsValue(DWORD FieldIndexCount, long *FieldIndexArray,VARIANT* FieldsValue);// 按照需要设置指定列的值
bool AddNewRecord(void);
bool Update(bool isUpdateOrCancelUpdate);
bool UpdateBatch(bool isUpdateOrCancelUpdate);
bool GetRecordCount(LONG *pRecordCount);
bool DatabaseIsOpen(void);
bool RecordsetIsOpen(void);
bool GetRecordsetAllFieldsValue(long *pRowCount,long *pFieldCount,VARIANT** ppFieldsValue);
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -