nbsp;break;
default:
#ifdef _DEBUG
AfxMessageBox("未处理的字段数据类型,请处理!");
#else
break;
#endif
break;
}
}
else
{
cVal[0]=''\0'';
}
return TRUE;
}
BOOL CBBRstValues::GetValueLong(long *lVal, long lIndex)
{
_variant_t vIndex(lIndex);
return GetValueLong(lVal,vIndex);
}
BOOL CBBRstValues::GetValueLong(long *lVal, LPCSTR lpszIndex)
{
_variant_t vIndex(lpszIndex);
return GetValueLong(lVal,vIndex);
}
BOOL CBBRstValues::VerifyVTData(char *pData)
{
if(pData == NULL)
{
return FALSE;
}
return TRUE;
}
BOOL CBBRstValues::VerifyVTData(_variant_t &value)
{
if(value.vt == VT_NULL)
{
return FALSE;
}
return TRUE;
}
BOOL CBBRstValues::GetValueStr(CString& str,LPCSTR lpszFieldName,int nFieldLen/*=-1*/)
{
_variant_t vIndex(lpszFieldName);
return GetValueStr(str,vIndex,nFieldLen);
}
BOOL CBBRstValues::GetValueStr(CString& str,UINT nFieldIndex,int nFieldLen/*=-1*/)
{
_variant_t vIndex((long)nFieldIndex);
return GetValueStr(str,vIndex,nFieldLen);
}
BOOL CBBRstValues::GetValueStr(CString& str,_variant_t &vIndex,int nFieldLen/*=-1*/)
{
TCHAR buffer[1024];
if(nFieldLen > 1023)
nFieldLen = 1023;
BOOL bResult=GetValueStr((char*)buffer,vIndex,nFieldLen);
str.Format(buffer);
str.TrimRight();
return bResult;
}
BOOL CBBRstValues::GetValueFloat(float* fVal,_variant_t &vIndex)
{
_variant_t value;
try
{
if((*m_prsThis)==NULL||(*m_prsThis)->State==adStateClosed)
{
#ifdef _DEBUG
AfxMessageBox("记录集未打开!");
#else
MessageBox(NULL,"无法读取数据库
资料,可能数据库连接已经断开,请重新连接、然后重试。","连接问题",MB_ICONINFORMATION);
#endif
return FALSE;
}
if((*m_prsThis)->adoEOF)
{
fVal=0;
return FALSE;
}
value=(*m_prsThis)->GetCollect(vIndex);
}
catch(_com_error)
{
ReportError();
return FALSE;
}
catch()
{
AfxMessageBox("数据库字段访问未知错误!请检查连接数据库结构是否已经更改。",MB_ICONINFORMATION);
return FALSE;
}
if(VerifyVTData(value))
{
*fVal = float(value);
}
else
{
*fVal = 0;
}
return TRUE;
}
BOOL CBBRstValues::GetValueFloat(float* fVal,long lIndex)
{
_variant_t vIndex(lIndex);
return GetValueFloat(fVal,vIndex);
}
BOOL CBBRstValues::GetValueFloat(float* fVal,CString strIndex)
{
_variant_t vIndex(strIndex);
return GetValueFloat(fVal,vIndex);
}
BOOL CBBRstValues::GetValueStr(char *cVal,long lIndex,int nFieldLen)
{
_variant_t vIndex;
vIndex=_variant_t(lIndex);
return GetValueStr(cVal,vIndex);
}
BOOL CBBRstValues::GetValueStr(char *cVal,CString strIndex,int nFieldLen)
{
_variant_t vIndex;
vIndex=_variant_t(strIndex);
return GetValueStr(cVal,vIndex);
}
void CBBRstValues::ReportError()
{