本文整理汇总了C++中_RecordsetPtr::MoveNext方法的典型用法代码示例。如果您正苦于以下问题:C++ _RecordsetPtr::MoveNext方法的具体用法?C++ _RecordsetPtr::MoveNext怎么用?C++ _RecordsetPtr::MoveNext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类_RecordsetPtr
的用法示例。
在下文中一共展示了_RecordsetPtr::MoveNext方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReplaceAreaValue
//替换指定范围的某字段的值.
bool CFoxBase::ReplaceAreaValue(_RecordsetPtr pRs, CString strField, CString strValue, int startRow, int endRow)
{
if(startRow > endRow)
{
endRow = startRow;
}
if( endRow <= 0 )
{
return false;
}
if( endRow > pRs->GetRecordCount() )
{
return false;
}
if( pRs->GetRecordCount() <= 0 )
{
return false;
}
pRs->MoveFirst();
for(int i=1; i<=endRow && !pRs->adoEOF; i++, pRs->MoveNext())
{
if( i >= startRow )
{
pRs->PutCollect(_variant_t(strField), _variant_t(strValue));
pRs->Update();
}
}
return true;
}
示例2: RecNo
///////////////////////////////////////////////
//
//返回当前记录集的游标位置
//
//IRecordset[in] 记录集智能指针
//
//函数成功返回当前记录集的游标位置,否则返回-1
//
long CFoxBase::RecNo(_RecordsetPtr IRecordset)
{
long pos=0;
long i;
if(IRecordset==NULL)
return -1;
if(IRecordset->adoEOF && IRecordset->BOF)
return -1;
while(!IRecordset->GetBOF())
{
pos++;
IRecordset->MovePrevious();
}
i=pos;
i--;
IRecordset->MoveFirst();
while(i>0)
{
i--;
IRecordset->MoveNext();
}
return pos;
}
示例3: GetRecordCount
UINT CBADO::GetRecordCount( _RecordsetPtr pRecordset )
{
int nCount = 0;
try
{
if(pRecordset->EndOfFile)
{
Sleep(1);
return 0;
}
pRecordset->MoveFirst();
}
catch(...)
{
return 0;
}
if (pRecordset->FirstOfFile)
return 0;
while(!pRecordset->EndOfFile)
{
pRecordset->MoveNext();
nCount = nCount + 1;
}
pRecordset->MoveFirst();
return nCount;
}
示例4: GetDataStr
CString CADODB::GetDataStr(_RecordsetPtr pRecordset)
{
if (NULL == pRecordset) return _T("");
CString strData;
int nFieldsCount = pRecordset->Fields->GetCount(); // 字段数;
for (int i = 0; i < nFieldsCount; i++)
{
char *pszName = _com_util::ConvertBSTRToString(pRecordset->Fields->GetItem((long)i)->GetName()); // 字段名
strData += pszName;
strData += _T("\t");
delete[] pszName;
}
strData += _T("\n");
while (!pRecordset->EndOfFile) //遍历所有记录
{
for (int i = 0; i < nFieldsCount; i++)
{
strData += pRecordset->GetCollect((long)i);
strData += _T("\t");
}
strData += _T("\n");
pRecordset->MoveNext();
}
return strData;
}
示例5: QueryByCondit
void CBllHelp::QueryByCondit(_RecordsetPtr pRecordSet,vector<string> &vecField, vector<string> &vecRecordSet, long &lFieldCounts)
{
//判断存在记录
if(pRecordSet == NULL)
return ;
if (!vecRecordSet.empty())
{
vecRecordSet.clear();
}
if (!vecField.empty())
{
vecField.clear();
}
try
{
//字段个数
lFieldCounts = pRecordSet->GetFields()->GetCount();
adoDataTypeEnum enumDataType;
_bstr_t str;
//字段名称、类型、大小
for(long i = 0; i<lFieldCounts; i++)
{
str= pRecordSet->GetFields()->GetItem(i)->GetName();
vecField.push_back((LPSTR)str);
enumDataType = pRecordSet->GetFields()->GetItem(i)->GetType();
str = GetDataTypeString(enumDataType);
vecField.push_back((LPSTR)str);
str = pRecordSet->GetFields()->GetItem(i)->GetDefinedSize();
vecField.push_back((LPSTR)str);
}
pRecordSet->MoveFirst();
long lCounts = 0;
_variant_t var;
//获取记录
while(!pRecordSet->adoEOF)
{
for(long j=0; j<lFieldCounts; j++)
{
var=pRecordSet->GetCollect(j);
str=(_bstr_t)(var.vt==1?"":var);
vecRecordSet.push_back((LPSTR)str);
}
pRecordSet->MoveNext();
lCounts++;
}
}
catch(_com_error e)
{
//AfxMessageBox("记录为空");
}
}
示例6: ReplAll
///////////////////////////////////////////////////////////
//
//替换记录集中选中字段所有的值
//
//IRecordset[in] 记录集智能指针
//FieldsName[in] 字段名
//Value[in] 输入替换FieldsName字段的值
//
//函数成功返回TRUE,否则返回FALSE
//当函数成功返回时,当前游标指针指向记录集最后一个记录的后面
//
BOOL CFoxBase::ReplAll(_RecordsetPtr IRecordset, _variant_t FieldsName, _variant_t Value)
{
if(IRecordset==NULL)
return FALSE;
IRecordset->MoveFirst();
while(!IRecordset->adoEOF)
{
IRecordset->PutCollect(FieldsName,Value);
IRecordset->Update();
IRecordset->MoveNext();
}
return TRUE;
}
示例7: main
void main()
{
string sql;
_RecordsetPtr m_pRecordset;
sql="select * from testDB";
_bstr_t bstr_t(sql.c_str());
m_pRecordset= GetRecordset(bstr_t);
_variant_t vID;
_variant_t vName;
_variant_t vAge;
while(!m_pRecordset->adoEOF)
{
//取得第1列的值,从0开始计数,你也可以直接给出列的名称,如下一行
vID = m_pRecordset->GetCollect(_variant_t((long)0));
vName = m_pRecordset->GetCollect("Name");
vName = m_pRecordset->GetCollect("Age");
cout<<vID.iVal<<endl;
//cout<<(char*)(_bstr_t)vName<<endl;
//cout<<(LPCTSTR)(_bstr_t)vName<<endl;
cout<<vName.bstrVal<<endl;
cout<<vAge.intVal<<endl;
m_pRecordset->MoveNext();
}
//添加3条新的纪录
for(int i=0;i<3;i++){
m_pRecordset->AddNew();
m_pRecordset->PutCollect("ID", _variant_t("3"));
m_pRecordset->PutCollect("Name", _variant_t("edward"));
m_pRecordset->PutCollect("Age", _variant_t("18"));
}
m_pRecordset->Update();
cout<<"添加成功"<<endl;
//移到首条记录
//m_pRecordset->MoveFirst();
//删除当前记录
//m_pRecordset->Delete(adAffectCurrent);
ExitConnect();
}
示例8: ReplNext
///////////////////////////////////////////////////////////
//
//替换从记录集中选中字段指定条记录的值(相当于FOXPRO中 Replace Next)
//
//IRecordset[in] 记录集智能指针
//FieldsName[in] 字段名
//Value[in] 输入替换FieldsName字段的值
//num[in] 需替换的记录数
//
//函数成功返回TRUE,否则返回FALSE
//函数从当前游标位置开始替换
//当函数成功返回时,当前游标指针指向最后修改的记录集上
//当需替换的记录数超过最后一条记录时,游标指向最后一条记录的后面
//
BOOL CFoxBase::ReplNext(_RecordsetPtr IRecordset, _variant_t FieldsName, _variant_t Value, int num)
{
if(IRecordset==NULL || num<=0)
return FALSE;
while(!IRecordset->adoEOF)
{
IRecordset->PutCollect(FieldsName,Value);
IRecordset->Update();
num--;
if(num<=0)
break;
IRecordset->MoveNext();
}
return TRUE;
}
示例9: GetRecordCount
int RxADO::GetRecordCount(_RecordsetPtr pRst)
{
int nCount=0;
try{
pRst->MoveFirst();
}
catch(...)
{
return 0;
}
if(pRst->_EOF)
return 0;
while (!pRst->_EOF)
{
pRst->MoveNext();
nCount=nCount+1;
}
pRst->MoveFirst();
return nCount;
}
示例10: GetRecordCount
DWORD CADODatabase::GetRecordCount(_RecordsetPtr m_pRs)
{
DWORD numRows = 0;
numRows = m_pRs->GetRecordCount();
if(numRows == -1)
{
if(m_pRs->EndOfFile != VARIANT_TRUE)
m_pRs->MoveFirst();
while(m_pRs->EndOfFile != VARIANT_TRUE)
{
numRows++;
m_pRs->MoveNext();
}
if(numRows > 0)
m_pRs->MoveFirst();
}
return numRows;
}
示例11: CopyData
BOOL CFoxBase::CopyData(_RecordsetPtr &IRecordS, _RecordsetPtr &IRecordD)
{
_variant_t TempValue;
short Item;
FieldsPtr IFields;
FieldPtr IField;
if(IRecordS==NULL || IRecordD==NULL)
{
ExceptionInfo(_T("Source Recordset or destination Recordset cann't be empty"));
return FALSE;
}
if(IRecordS->adoEOF && IRecordS->BOF)
{
return TRUE;
}
if(!IRecordD->adoEOF || !IRecordD->BOF)
{
try
{
IRecordD->MoveLast();
}
catch(_com_error &e)
{
ExceptionInfo(e);
return FALSE;
}
}
try
{
IRecordS->MoveFirst();
}
catch(_com_error &e)
{
ExceptionInfo(e);
return FALSE;
}
try
{
while(!IRecordS->adoEOF)
{
IRecordS->get_Fields(&IFields);
IRecordD->AddNew();
for(Item=0;Item<IFields->GetCount();Item++)
{
IFields->get_Item(_variant_t(Item),&IField);
TempValue=IRecordS->GetCollect(_variant_t(IField->GetName()));
IRecordD->PutCollect(_variant_t(IField->GetName()),TempValue);
IField.Release();
}
IRecordD->Update();
IFields.Release();
IRecordS->MoveNext();
}
}
catch(_com_error &e)
{
ExceptionInfo(e);
return FALSE;
}
return TRUE;
}
示例12: LocateForCurrent
////////////////////////////////////////////////////
//
//从表的当前记录开始寻找指定的逻辑关系
//
//IRecordset[in] 记录集智能指针
//FieldsName[in] 字段名
//Relations[in] 逻辑关系,等于、不等于……
//Value[in] 输入与FieldsName比较的值
//
//函数成功返回TRUE,否则返回FALSE
//如果需比较的字段与关系不匹配会抛出_com_error异常
//指针指向找到的记录上
//
BOOL CFoxBase::LocateForCurrent(_RecordsetPtr IRecordset, _variant_t FieldsName, int Relations, _variant_t Value)
{
_variant_t tempvalue;
CString tempstr;
if(IRecordset==NULL || Value.vt==VT_NULL)
return FALSE;
while(!IRecordset->adoEOF)
{
tempvalue=IRecordset->GetCollect(FieldsName);
if(tempvalue.vt==VT_NULL)
{
IRecordset->MoveNext();
continue;
}
switch(Relations)
{
case CFoxBase::EQUAL: // 等于
if(Value.vt==VT_BSTR)
{
// tempstr=(TCHAR*)(_bstr_t)tempvalue;
// if(tempstr.Find((TCHAR*)(_bstr_t)Value) != -1)
// return TRUE;
// else
// break;
tempstr = vtos(tempvalue);
if (!tempstr.Compare(vtos(Value)))
{
return TRUE;
}
else
{
break;
}
}
if(tempvalue==Value)
return TRUE;
else
break;
case CFoxBase::UNEQUAL: //不等于
if(tempvalue!=Value)
return TRUE;
else
break;
case CFoxBase::GREATER: //大于
if((double)tempvalue>(double)Value)
return TRUE;
else
break;
case CFoxBase::GREATER_OR_EQUAL: //大于等于
if((double)tempvalue>=(double)Value)
return TRUE;
else
break;
case CFoxBase::LESS: //小于
if((double)tempvalue<(double)Value)
return TRUE;
else
break;
case CFoxBase::LESS_OR_EQUAL: //小于等于
if((double)tempvalue<=(double)Value)
return TRUE;
else
break;
default:
return FALSE;
}
IRecordset->MoveNext();
}
if(IRecordset->adoEOF)
return FALSE;
//.........这里部分代码省略.........
示例13: InsertNew
/////////////////////////////////////////////////////
//
// 在记录集的当前位置插入一条新记录
//
// IRecord[in] 记录集智能指针
//
// 函数成功返回TRUE,否则返回FALSE
// 如果有异常将调用ExceptionInfo函数
//
// 函数成功后记录集将指向新插入的空记录
//
BOOL CFoxBase::InsertNew(_RecordsetPtr &IRecord,int after)
{
int pos;
CMap<short,short&,_variant_t,_variant_t&> FieldMap;
CMap<short,short&,_variant_t,_variant_t&> newFieldMap; //将新增加的记录的值记下来
_variant_t TempValue;
short Item;
FieldsPtr IFields;
FieldPtr IField;
int pos1;
int nCount; //字段个数.
if(IRecord==NULL)
{
ExceptionInfo(_T("Recordset cann't be empty"));
return FALSE;
}
//如果记录集为空将插入一条新记录
if(IRecord->adoEOF && IRecord->BOF)
{
try
{
IRecord->AddNew();
IRecord->Update();
}
catch(_com_error &e)
{
ExceptionInfo(e);
return FALSE;
}
return TRUE;
}
else if(IRecord->adoEOF)
{
IRecord->AddNew();
IRecord->Update();
IRecord->MoveLast();
return true;
}
for(pos=0; !IRecord->adoEOF ;pos++)
{
try
{
IRecord->MoveNext();
}
catch(_com_error &e)
{
ExceptionInfo(e);
return FALSE;
}
}
//
// 查如一条新记录,并将刚开始所指的以后的记录向后移
//
try
{
IRecord->AddNew();
IRecord->Update();
IRecord->MoveLast();
//将新增加的记录的值记下来.
IFields = IRecord->GetFields();
nCount = IFields->GetCount(); //字段个数
for (Item = 0; Item < nCount; Item++)
{
newFieldMap[Item] = IRecord->GetCollect(_variant_t(Item));
}
IFields.Release();
//
IRecord->MovePrevious();
}
catch(_com_error &e)
{
ExceptionInfo(e);
return FALSE;
}
if(after==1)
pos--; //使pos再减一,变成在指针的当前位置上加入一条新记录,insert blank
pos1=pos;
while(pos>0)
{
try
{
for(Item=0;Item<nCount;Item++)
//.........这里部分代码省略.........