我已经声明了以下结构来保存通过 getfieldvalue 从访问数据库检索到的数据:错误出现在 Spds_old->Time_old.push_back(OldTime); 在数据库中,该值为下午 3:00:00。你能告诉我错误吗?谢谢你。如果您需要更多信息,请告诉我。谢谢你-基兰
typedef struct {
std::vector<CString> pname_old;
std::vector<CDBVariant> Date_old;
std::vector<CDBVariant> Time_old;
} Spd_old;
Spd_old *Spds_old;
然后在cpp文件中这是代码
CRecordset rset(&pdatabase);
CString pName;
CDBVariant OldDate;
CDBVariant OldTime;
CString selectionStr = "SELECT I.PType,I.Date,I.Time FROM CCYX I,(select PType, MAX(Date) AS Date1";
selectionStr += " FROM CCYX GROUP BY PType) T WHERE I.PType = T.PType AND I.Date =T.Date1";
try
{
if(rset.Open(CRecordset::forwardOnly, selectionStr))
{
try
{
while(!(rset.IsBOF()&&rset.IsEOF()))
{
m_Log->Log("Copying Previous spd Values from Access DB");
rset.GetFieldValue((short)0 ,pName );
rset.GetFieldValue((short)1 ,OldDate );
rset.GetFieldValue((short)2 ,OldTime);
Spds_old->pname_old.push_back(pName);
Spds_old->Date_old.push_back(OldDate);
Spds_old->Time_old.push_back(OldTime);