T * FROM "+strTableName);
loc_pQueryDef->Create(NULL,Sqlstr);
loc_pRecordset.Open(loc_pQueryDef);
m_nRecordNumber=0;
while(!loc_pRecordset.IsEOF())
{ m_nRecordNumber++;
loc_pRecordset.MoveNext( ); }
return TRUE;
}
bool CDataBaseOperate::GetRecord(int nRecordPosition)
{ //得到字段名
CDaoFieldInfo fieldinfo;
CString strZTNRName,strNDXSName,strFZName,strDAName,strBZName;
m_nNumberPosition=nRecordPosition;
loc_pTable->GetFieldInfo(1,fieldinfo,AFX_DAO_PRIMARY_INFO);
strZTNRName=fieldinfo.m_strName;
loc_pTable->GetFieldInfo(2,fieldinfo,AFX_DAO_PRIMARY_INFO);
strNDXSName=fieldinfo.m_strName;
loc_pTable->GetFieldInfo(3,fieldinfo,AFX_DAO_PRIMARY_INFO);
strFZName=fieldinfo.m_strName;
loc_pTable->GetFieldInfo(4,fieldinfo,AFX_DAO_PRIMARY_INFO);
strDAName=fieldinfo.m_strName;
loc_pTable->GetFieldInfo(5,fieldinfo,AFX_DAO_PRIMARY_INFO);
strBZName=fieldinfo.m_strName;
int iNumber=1;
COleVariant OleField;
loc_pRecordset.MoveFirst();
//得到指定记录的字段值,存入五个变量中
while(!loc_pRecordset.IsEOF())
{ if (iNumber==nRecordPosition)
{ loc_pRecordset.GetFieldvalue(strZTNRName,OleField);
m_strZTNRvalue=(CString)V_BSTRT(&OleField);
m_strZTNRvalue.TrimRight();
loc_pRecordset.GetFieldvalue(strNDXSName,OleField);
m_nNDXSvalue=(long)V_I4(&OleField);
loc_pRecordset.GetFieldvalue(strFZName,OleField);
m_nFZvalue=(double)V_R8(&OleField);
loc_pRecordset.GetFieldvalue(strDAName,OleField);
m_strDAvalue=(CString)V_BSTRT(&OleField);
m_strDAvalue.TrimRight();
loc_pRecordset.GetFieldvalue(strBZName,OleField);
m_strBZvalue="";
m_strBZvalue=(CString)V_BSTRT(&OleField);
m_strBZvalue.TrimRight();
loc_pRecordset.MoveLast();
loc_pRecordset.MoveNext(); }
else
{ loc_pRecordset.MoveNext( );
iNumber++; }
}
loc_pRecordset.MoveFirst();
int jj=1;
while (jj<nRecordPosition)
{ loc_pRecordset.MoveNext();
jj++; }
return TRUE;
}
CString CDataBaseOperate::GetZTNRvalue()
{ return m_strZTNRvalue;}
long CDataBaseOperate::GetNDXSvalue()
{ return m_nNDXSvalue;}
double CDataBaseOperate::GetFZvalue()
{ return m_nFZvalue;}
CString CDataBaseOperate::GetDAvalue()
{ return m_strDAvalue;}
CString CDataBaseOperate::GetBZvalue()
{ return m_strBZvalue;}