#include "clsrecordset.h"
#include <stdlib.h>
ClsRecordset::ClsRecordset(ClsDbTools *pDbt)
{
/*get record volume*/
#ifdef _FORLINUX_
m_dbList = pDbt->m_recordList;
#else
m_dbvector = pDbt->m_datavector;
#endif
m_gpointer = NULL;
m_setcolName = NULL;
m_pos = 0;
/*get field number*/
m_setcolNum = pDbt->m_colNum;
/*get field name*/
m_setcolName = (char**)_tmalloc(m_setcolNum * (sizeof(char*)));
for (int i = 0; i < m_setcolNum; i++){
m_setcolName[i] = (char*)_tmalloc(128);
_tcscpy(m_setcolName[i], pDbt->m_colName[i]);
}
}
ClsRecordset::~ClsRecordset()
{
/*free record volume*/
#ifdef _FORLINUX_
m_dbList = NULL;
#else
m_dbvector.clear( );
#endif
for (int i = 0; i<m_setcolNum; i++){
_tfree(m_setcolName[i]);
}
_tfree(m_setcolName);
m_setcolName=NULL;
}
/******************************************************************
* function name : ClsRecordset::getPosition(int *iPosition)
* function description : get nonce position's point.
* finished date: 2004-8-18
* Author : FanZiqiang
* parameter: iPosition--return nonce row number.
* retrun value: SAN_SUCCESS--action succeed£»other--action failed
* restrained condition: NONE
* side effect: Describe NONE
******************************************************************/
int ClsRecordset::getPosition(int *iPosition)
{
int iRet = DATABASE_SUCCESS;
int maxRCount; //the record number
if (iPosition != NULL){
iRet = getRecordCount(&maxRCount); //get record number
if(DATABASE_SUCCESS == iRet){
if((m_pos >= 0)&&(m_pos < maxRCount)){
*iPosition = m_pos;
iRet = DATABASE_SUCCESS;
}
else{
iRet = DBT_MPOS_OVER_STEP;
}
}
}
else{
iRet = DBT_ERROR_POINTER_NULL;
}
return iRet;
}
/******************************************************************
* function name : ClsRecordset::Move(int iRowNum)
* function description : move point ,by row num.
* finished date: 2004-8-18
* Author : FanZiqiang
* parameter: iRowNum--row number
* retrun value: SAN_SUCCESS--action succeed£»other--action failed
* restrained condition: NONE
* side effect: Describe NONE
******************************************************************/
int ClsRecordset::Move(int iRowNum)
{
int iRet = DATABASE_SUCCESS;
int maxRCount;
iRet = getRecordCount(&maxRCount);//get record number
if(DATABASE_SUCCESS == iRet){
if((iRowNum >= 0)&&(iRowNum < maxRCount)){
m_pos = iRowNum;
iRet = DATABASE_SUCCESS;
}
else{
iRet = DBT_MPOS_OVER_STEP;
}
}
return iRet;
}
/*****************************************************************
* function name : ClsRecordset::MoveFirst()
* function description : move ponit to first.
* finished date: 2004-8-18
* Author : FanZiqiang
* parameter:
* retrun value: SAN_SUCCESS--action succeed£»other--action failed
* restrained condition: NONE
* side effect: Describe NONE
******************************************************************/
int ClsRecordset::MoveFirst()
{
int iRet = DATABASE_SUCCESS;
int maxRCount;
iRet = getRecordCount(&maxRCount);//get record number
if(DATABASE_SUCCESS == iRet){
if(maxRCount > 0){
m_pos = 0;
iRet = DATABASE_SUCCESS;
}
else{
iRet = DBT_EMPTY_REC;
}
}
return iRet;
}
/*****************************************************************
* function name : ClsRecordset::MoveLast()
* function description : move the point to last
* finished date: 2004-8-18
* Author : FanZiqiang
* parameter:
* retrun value: SAN_SUCCESS--action succeed£»other--action failed
* restrained condition: NONE
* side effect: Describe NONE
******************************************************************/
int ClsRecordset::MoveLast()
{
int iRet = DATABASE_SUCCESS;
int rcount;
iRet = getRecordCount(&rcount);//get record number
if(DATABASE_SUCCESS == iRet){
if(rcount > 0){
m_pos = (rcount-1);
iRet = DATABASE_SUCCESS;
}
else{
iRet = DBT_EMPTY_REC;
}
}
return iRet;
}
/******************************************************************
* function name : ClsRecordset::MovePrevious()
* function description : the point move previous.
* finished date: 2004-8-18
* Author : FanZiqiang
* parameter:
* retrun value: SAN_SUCCESS--action succeed£»other--action failed
* restrained condition: NONE
* side effect: Describe NONE
******************************************************************/
int ClsRecordset::MovePrevious()
{
int iRet = DATABASE_SUCCESS;
if( 0 == m_pos ){
iRet = DBT_POSITION_IS_FIRST;
}
else{
int maxRCount;
iRet = getRecordCount(&maxRCount);//get record number
if(DATABASE_SUCCESS == iRet){
if((m_pos > 0)&&(m_pos < maxRCount)){
m_pos--;
iRet = DATABASE_SUCCESS;
}
else{
iRet = DBT_MPOS_OVER_STEP;
}
}
}
return iRet;
}
/*****************************************************************
* function name : ClsRecordset::moveNext()
* function description : the point move next.
* finished date: 2004-8-18
* Author : FanZiqiang
* parameter:
* retrun value: SAN_SUCCESS--action succeed£»other--action failed
* restrained condition: NONE
* side effect: Describe NONE
*****************************************************************/
int ClsRecordset::MoveNext()
{
int iRet = DATABASE_SUCCESS;
int maxRCount;
iRet = getRecordCount(&maxRCount);//get record number
if(DATABASE_SUCCESS == iRet){
if(m_pos == (maxRCount-1)){
iRet = DBT_POSITION_IS_LAST;
}
else{
if((m_pos >= 0)&&(m_pos < (maxRCount-1))){
m_pos++;
iRet = DATABASE_SUCCESS;
}
else{
iRet = DBT_MPOS_OVER_STEP;
}
}
}
return iRet;
}
/*****************************************************************
* function name : ClsRecordset::getRecordCount(int *iRecordCount)
* function description : get record count.
* finished date: 2004-8-18
* Author : FanZiqiang
* parameter: iRecordCount--return record count
* retrun value: SAN_SUCCESS--action succeed£»other--action failed
* restrained condition: NONE
* side effect: Describe NONE
******************************************************************/
int ClsRecordset::getRecordCount(int *iRecordCount)
{
int iRet = DATABASE_SUCCESS;
unsigned int guint;
if (iRecordCount != NULL){
//get record number
#ifdef _FORLINUX_
guint = g_list_length(m_dbList);
#else
guint = m_dbvector.size();
#endif
*iRecordCount = guint;
iRet = DATABASE_SUCCESS;
}
else{
iRet = DBT_ERROR_POINTER_NULL;
}
return iRet;
}
/****************************************************************
* function name : ClsRecordset::getFieldCount(int *iFieldCount)
* function description : get field count.
* finished date: 2004-8-18
* Author : FanZiqiang
* parameter: iFieldCount--return field count
* retrun value: SAN_SUCCESS--action succeed£»other--action failed
* restrained condition: NONE
* side effect: Describe NONE
*****************************************************************/
int ClsRecordset::getFieldCount(int *iFieldCount)
{
int iRet = DATABASE_SUCCESS;
if (iFieldCount != NULL){
*iFieldCount = m_setcolNum;
iRet = DATABASE_SUCCESS;
}
else{
iRet = DBT_ERROR_POINTER_NULL;
}
return iRet;
}
/****************************************************************************
* function name : ClsRecordset::getFieldName(int fieldnum, char *sFieldName)
* function description : get a field name, by num.
* finished date: 2004-8-18
* Author : FanZiqiang
* parameter: fieldnum--the field number;
* sFieldName--return the field name
* retrun value: SAN_SUCCESS--action succeed£»other--action failed
* restrained condition: NONE
* side effect: Describe NONE
*******************************************************************
没有合适的资源?快使用搜索试试~ 我知道了~
调用sqlite开源数据的小程序,能够往数据库中写入数据
共16个文件
h:4个
cpp:3个
dsp:2个
5星 · 超过95%的资源 需积分: 48 29 下载量 184 浏览量
2008-09-17
17:04:16
上传
评论
收藏 202KB ZIP 举报
温馨提示
调用sqlite开源数据的小程序,能够往数据库中写入数据 希望对初用sqlite者有帮助
资源推荐
资源详情
资源评论
收起资源包目录
调用sqlite开源数据的小程序,能够往数据库中写入数据.zip (16个子文件)
sqlite-header-libs
sqlite3.h 62KB
sqlite3.dll 326KB
sqlite3.def 2KB
sqlite3_windows
test
test.plg 964B
test.cpp 3KB
test.dsp 4KB
sqldll
sqldll.ncb 89KB
sqldll.dsw 724B
clsrecordset.cpp 17KB
sqldll.plg 2KB
clsdbtools.h 3KB
sqldll.opt 44KB
clsrecordset.h 1KB
sqldll.dsp 4KB
dbmerror.h 2KB
clsdbtools.cpp 12KB
共 16 条
- 1
资源评论
- choco1mao2020-10-14好用,适合学习
blc_21cn
- 粉丝: 0
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功