3. dbconnection.h
#pragma once 【程序编程相关:Booth Algorithm】 【推荐阅读:类别管理完成 2004-08-01】 【扩展信息:破解本地的mysql用户名和密码!】#include <comutil.h>
#pragma comment(lib,"comsupp.lib")class cdbconnectionimpl ;
class cdbrecordset ;class afx_ext_class cdbconnection
{ friend class cdbrecordset ;public:
cdbconnection(void); virtual ~cdbconnection(void); /* * 设置数据库连接参数 * 参数: * [in] szservername -> 数据库所在机器的机器名或者ip地址 * [in] szbasename -> 数据库实例名称 * [in] szuser -> 数据库登陆用户名 * [in] szpasswd -> 登陆密码 */ void setparameters(lpctstr szservername,lpctstr szbasename,lpctstr szuser,lpctstr szpasswd) ;//是否连接已经打开
bool isopened(void) ;//打开连接
bool open(void) ;//开始事务
bool begintrans(void) ;//提交事务
bool committrans(void) ;//回滚事务
bool rollbacktrans(void) ;/*
* 执行sql语句,例如 insert , update 等,不返回记录 * 参数: * [in] szsql -> sql语句 * [out] pnrecordsaffected -> the number of records that the operation affected. */ bool execute(lpctstr szsql,int* pnrecordsaffected = null) ;/*
* 执行sql语句,并返回记录集 * 参数: * [in] szsql -> sql语句, select ...... * [out] recordset -> 本次查询得到的记录集 */ bool openrecordset(lpctstr szsql,cdbrecordset& rrecordset) ;//关闭连接
bool close(void) ;/*
* 设置错误信息 * 参数: * [in] szerrmsg -> 错误信息 * [in] szsourcefile -> 发生错误的源文件 * [in] nline -> 发生错误的行号 */ ... 下一页