C++ 操作Access
c++操作数据库,效率比其他的语言相对会快一点,尤其是操作大数据。#pragma once
/*
C++ Access数据库操作
QQ:728297725
*/
#ifndef YXB_CCONNECTION_H_H
#define YXB_CCONNECTION_H_H
// include flies //
//#include <afx.h>
#include "ADOCONST.h"
using namespace ADOCONST;
class CConnection
{
private:
_ConnectionPtr m_pConn;
CString m_sErrorMessage; //used to save error message
//Construction/Destruction //
public:
CConnection();
virtual ~CConnection();
// Property Get/Set Method //
public:
//Property: ConnectionString
CString GetConnectionString() const;
void SetConnectionString(char * charConn);
void SetConnectionString(CString strConn);
//Property: ConnectionTimeout
long GetConnectionTimeout() const;
void SetConnectionTimeout(long time);
//Property: CursorLocation
CursorLocationEnum GetCursorLocation() const;
void SetCursorLocation(CursorLocationEnum CursorLocation);
//Property: CommandTimeout
long GetCommandTimeout() const;
void SetCommandTimeout(long time);
//Property: State
ObjectStateEnum GetState() const;
//Property: m_sErrorMessage
CString GetErrorMessage() const;
//Property: m_pConn
_ConnectionPtr GetConnection() const;
// Core Method //
public:
bool Open(const CString strPath/*数据库的路径*/, CString UserID = L"", CString Password = L"", ConnectOptionEnum ConnectOption = ConnectOption::adConnectUnspecified);
bool OpenEx(const CString& ConnectionString/*数据库的连接串*/, CString UserID = L"", CString Password = L"", ConnectOptionEnum ConnectOption = ConnectOption::adConnectUnspecified);//ID和Password为空,因为要再连接字符串中去指明ID和密码
bool Close();
bool Cancel();
void Release();
bool RollbackTrans();
bool CommitTrans();
long BeginTrans();
};
#endif // #ifndef YXB_CONNECTION_H_H
文档来源:51CTO技术博客https://blog.51cto.com/u_10486491/3215396
页:
[1]