本文整理汇总了C++中_RecordsetPtr::GetCollect方法的典型用法代码示例。如果您正苦于以下问题:C++ _RecordsetPtr::GetCollect方法的具体用法?C++ _RecordsetPtr::GetCollect怎么用?C++ _RecordsetPtr::GetCollect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类_RecordsetPtr
的用法示例。
在下文中一共展示了_RecordsetPtr::GetCollect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ImportHangerRestraints
//吊架和支架数据的导入pfg20050615
//flag=0 为吊架; flag=1 为支架
//记录集是结果集 对应ZA表
//rsHR记录集是数据源集(弹簧、吊架)
//ltemp 支吊架号
void CAESARIIToPHS::ImportHangerRestraints(_RecordsetPtr rsData,_RecordsetPtr rsHR,long <emp,long &FileNameID,char *strPSAVER,long &node,int flag)
{
_variant_t tmpvar;
long lTmp;
try
{
if(flag)
{
tmpvar=rsHR->GetCollect(_T("node_num"));
lTmp=vtoi(rsHR->GetCollect(_T("RES_TYPEID")));//pfg20050624
}
else
{
tmpvar=rsHR->GetCollect(_T("node"));
}
if(tmpvar.vt==VT_EMPTY||tmpvar.vt==VT_NULL)
{
return;
}
else
{
node=vtoi(tmpvar);
}
if ( node < 1e-6 ) //5.2版本中所有的约束信息会导入INPUT_RESTRAINTS表中(同一约束点会有四条记录,所以会有NODE_NUM为-1情况)
return;
if(rsData->GetRecordCount()>0)
{
rsData->MoveFirst();
}
rsData->Filter = _variant_t(CString("[jsdbh1] = ") + ltos(node)+" AND [FileNameID]="+ltos(FileNameID));
if (rsData->adoEOF&&rsData->BOF)
{
rsData->AddNew();
rsData->PutCollect("VolumeID",_variant_t(EDIBgbl::SelVlmID));
rsData->PutCollect("zdjh",_variant_t((long)(ltemp+1)));
rsData->PutCollect("FileNameID",_variant_t(FileNameID));
ltemp++;
rsData->Update();
}
rsData->PutCollect("PSAver", _variant_t(strPSAVER));
rsData->PutCollect("UPxyz",_variant_t((long)m_iUPxyz));
rsData->PutCollect("JSDBH1", _variant_t((long)node));
rsData->Update();
}
catch (_com_error &e)
{
CString strMsg;
strMsg.Format("%s:%d %s", __FILE__, __LINE__, (LPSTR)e.Description());
AfxMessageBox(strMsg);
}
}
示例2: 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;
}
示例3: 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();
}
示例4: OnReadGroup
int CNetworkTree::OnReadGroup(_RecordsetPtr xRecordset, CString& xUserGrp, CString& xGroupId)
{
_variant_t TheValue = xRecordset->GetCollect( "xentercode" );
ASSERT( VT_NULL != TheValue.vt ); xGroupId = (LPCTSTR)(_bstr_t)TheValue;
TheValue = xRecordset->GetCollect( "xentername" );
if ( VT_NULL == TheValue.vt ) xUserGrp = _T("<NULL>");
else xUserGrp = (LPCTSTR)(_bstr_t)TheValue;
TheValue = xRecordset->GetCollect( "xexpiredate" );
if ( VT_NULL != TheValue.vt )
{
COleDateTime tt = TheValue; tt.SetTime( 0, 0, 0 );
COleDateTimeSpan tSpan = COleDateTime::GetCurrentTime() - tt;
if ( tSpan.GetTotalDays() > 0 ) return EBase_NoPay;
}
return 0;
}
示例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: GetCollectByte
BYTE GetCollectByte(_RecordsetPtr m_pRecordset, char* key)
{
try{
VARIANT var = m_pRecordset->GetCollect(key);
if(var.vt == VT_NULL)
return NULL;
return var.intVal;
}
catch(_com_error& e){
AfxMessageBox(e.ErrorMessage());
}
return NULL;
}
示例7: GetCollectMyLong
long GetCollectMyLong(_RecordsetPtr m_pRecordset, char* key)
{
try{
VARIANT var = m_pRecordset->GetCollect(key);
if(var.vt == VT_NULL)
return NULL;
return (long)var.dblVal;
}
catch(_com_error& e){
AfxMessageBox(e.ErrorMessage());
}
return NULL;
}
示例8: GetCollectString
CString GetCollectString(_RecordsetPtr m_pRecordset, char* key)
{
try{
VARIANT var = m_pRecordset->GetCollect(key);
CString res;
if(var.vt == VT_NULL)
return res;
res.Format("%s", (char*)(_bstr_t)var);
return res;
}
catch(_com_error& e){
AfxMessageBox(e.ErrorMessage());
}
return "";
}
示例9: GetTbValue
//////////////////////////////////////////////////////////////////////////////////////////////
//
// 从记录集中返回指定字段的值
//
// IRecordset[in] 记录集智能指针
// FieldsName[in] 字段名
// RetValue[out] 返回的变量
//
// 如果有异常将调用ExceptionInfo函数
//
void CFoxBase::GetTbValue(_RecordsetPtr IRecordset, _variant_t FieldsName, int &RetValue)
{
_variant_t TempValue;
CString strTemp;
if(IRecordset==NULL)
return;
try
{
TempValue=IRecordset->GetCollect(FieldsName);
if(TempValue.vt!=VT_NULL)
{
if(TempValue.vt==VT_BSTR)
{
CString Temp;
Temp=(TCHAR*)(_bstr_t)TempValue;
Temp.TrimLeft();
if(Temp.GetLength()==0)
{
RetValue=0;
//break;
return;
}
}
RetValue=(long)TempValue;
}
else
{
RetValue=0;
}
}
catch(_com_error &e)
{
RetValue=0;
// ExceptionInfo(e);
strTemp.Format(_T("错误在从%s字段读取数据时"),(LPCTSTR)(_bstr_t)FieldsName);
Exception::SetAdditiveInfo(strTemp);
ReportExceptionErrorLV2(e);
throw;
}
}
示例10: GetCollectDate
CString GetCollectDate(_RecordsetPtr m_pRecordset, char* key)
{
try{
VARIANT var = m_pRecordset->GetCollect(key);
if(var.vt == VT_NULL)
return "";
SYSTEMTIME st;
VariantTimeToSystemTime(var.date, &st);
CString date;
date.Format("%d-%02d-%02d %02d:%02d", st.wYear,st.wMonth,st.wDay,st.wHour,st.wMinute);
return date;
}
catch(_com_error& e){
AfxMessageBox(e.ErrorMessage());
}
return "";
}
示例11: LoadFrom
BOOL CPagerChannel::LoadFrom(_RecordsetPtr xRecordset)
{
m_pRecordset = xRecordset->Clone( adLockOptimistic );
m_pRecordset->Filter = "xjsjbh = " + (_bstr_t)xRecordset->GetCollect("xjsjbh");
//_variant_t xjsjbh = m_pRecordset->GetCollect( "xjsjbh" );
// theApp.Message(MSG_ERROR,"---------->debug:[%i][%i] reccc=%i", m_nChan, xjsjbh.lVal,
// m_pRecordset->GetRecordCount());
CDialPacket* pPacket = new CDialPacket;
pPacket->SetLocalId( "96031222" );
_variant_t TheValue = m_pRecordset->GetCollect( "xPhoneNum" );
if ( VT_NULL == TheValue.vt ) pPacket->SetRemoteId( "" );
else pPacket->SetRemoteId( (LPCTSTR)(_bstr_t)TheValue );
TheValue = m_pRecordset->GetCollect( "xCaller" );
if ( VT_NULL == TheValue.vt ) pPacket->SetFeeNumber( "" );
else pPacket->SetFeeNumber( (LPCTSTR)(_bstr_t)TheValue );
CHAR xCallerId[MAX_PHONE + 1]; ZeroMemory(xCallerId, MAX_PHONE + 1);
pPacket->GetFeeNumber(xCallerId); pPacket->SetCallerId(xCallerId);
#if 1 // 重新指定计费号码
TheValue = m_pRecordset->GetCollect( "xFeeNumber" );
if ( VT_NULL != TheValue.vt ) pPacket->SetFeeNumber( (LPCTSTR)(_bstr_t)TheValue );
#endif
OnDialPacket( pPacket ); pPacket->Release();
#if 1
TheValue = m_pRecordset->GetCollect( "xPCMName" );
CString xUsrLvFile = (LPCTSTR)(_bstr_t)TheValue;
xUsrLvFile.TrimLeft(); xUsrLvFile.TrimRight();
CString xCallType = ReadPagerType( xUsrLvFile, CA_HOOK );
if ( xCallType.CompareNoCase(CallType) ) CopyMemory( CallType, (LPCTSTR)(xCallType), MAX_CALLTYPE );
//if ( IsMusic(pPager->UsrLvFile) ) CopyMemory( pPager->CallType, "BEST", MAX_CALLTYPE );
#endif
UpdateState( _PENDING_ );
m_bPending = TRUE;
return TRUE;
}
示例12: GetFieldValue
DWORD CNHSQLServerDBO::GetFieldValue(const _RecordsetPtr &pRecordset, _variant_t &vFieldValue, const wchar_t *const pwchFieldName)
{
assert(NULL != pRecordset);
assert(NULL != pwchFieldName);
DWORD dwReturn(0x00);
try
{
vFieldValue = pRecordset->GetCollect(_variant_t(pwchFieldName));
}
catch (_com_error &e)
{
//#ifdef _DEBUG
const int nErrMsgLength(MAX_PATH);
wchar_t *pwchErrMsg = new wchar_t[nErrMsgLength]();
_snwprintf_s(pwchErrMsg, nErrMsgLength, _TRUNCATE, L"CNHSQLServerDBO::GetFieldValue发生错误(FieldName:%s)。", pwchFieldName);
// 输出错误信息到输出窗口
OutputDebugStringW(L"\t");
OutputDebugStringW(pwchErrMsg);
OutputDebugStringW(L"\n");
// 输出错误信息到日志文件
if (0 != wcscmp(m_wchLogFilePath, L""))
{
// 当日志文件路径不为空时,写日志
CNHLogAPI::WriteLogEx(m_wchLogFilePath, LOG_ERR, L"NHSQLServerDBO", pwchErrMsg);
}
if (NULL != pwchErrMsg)
{
delete[] pwchErrMsg;
pwchErrMsg = NULL;
}
OutputDBErrMsg(e);
//#endif
dwReturn = 0x01;
}
return dwReturn;
}
示例13: 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;
}
示例14: 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;
//.........这里部分代码省略.........
示例15: 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++)
//.........这里部分代码省略.........