strQuery = "select rpk from phy_exp where 班级 = ‘00812’";
//满足 班级 = ‘00812’的记录有几条
theApp.ADOExecute(theApp.m_pADOSet,strQuery);
int iCount = theApp.m_pADOSet->GetRecordCount();
theApp.m_pADOSet->MoveFirst(); for (int i=0; i<iCount; i++)
{
…………
strQuery = "select * from phy_pro where 学号 = ‘00070001’ ";
theApp.ADOExecute(theApp.m_pADOSet,strQuery);'
int jCount = theApp.m_pADOSet->GetRecordCount();
for (int j=0; j<jCount; j++)
{
……………………
theApp.m_pADOSet->MoveNext();
}
theApp.m_pADOSet->MoveNext(); //为什么在这句的时候就不能执行而报错
}
应该怎么修改???
//满足 班级 = ‘00812’的记录有几条
theApp.ADOExecute(theApp.m_pADOSet,strQuery);
int iCount = theApp.m_pADOSet->GetRecordCount();
theApp.m_pADOSet->MoveFirst(); for (int i=0; i<iCount; i++)
{
…………
strQuery = "select * from phy_pro where 学号 = ‘00070001’ ";
theApp.ADOExecute(theApp.m_pADOSet,strQuery);'
int jCount = theApp.m_pADOSet->GetRecordCount();
for (int j=0; j<jCount; j++)
{
……………………
theApp.m_pADOSet->MoveNext();
}
theApp.m_pADOSet->MoveNext(); //为什么在这句的时候就不能执行而报错
}
应该怎么修改???
for (int j=0; j<jCount; j++)
{
……………………
theApp.m_pADOSet->MoveNext();
}
theApp.m_pADOSet->MoveNext(); //已经是最后了,不能再移了!!
可以改成这样:
while (!(theApp.m_pADOSet->adoEOF))
{
...
theApp.m_pADOSet->MoveNext();
}
分别打开的是不同的表。
所以应该不是So1o() 所说的问题而且有
int iCount = theApp.m_pADOSet->GetRecordCount();
int jCount = theApp.m_pADOSet->GetRecordCount();
控制
一个当然会出错啦 //满足 班级 = ‘00812’的记录有几条
strQuery = "select rpk from phy_exp where 班级 = '00812'";
theApp.ADOExecute(theApp.m_pADOSetAAA, strQuery);
while (!(theApp.m_pADOSetAAA->adoEOF))
{
…………
strQuery = "select * from phy_pro where 学号 = ‘00070001’ ";
theApp.ADOExecute(theApp.m_pADOSet,strQuery);'
while (!(theApp.m_pADOSet->adoEOF))
{
……………………
theApp.m_pADOSet->MoveNext();
}
theApp.m_pADOSetAAA->MoveNext(); //另一个纪录集
}
theApp.m_pADOSet->MoveLast();
strQuery = "select * from phy_pro where 学号 = ‘00070001’ ";
theApp.ADOExecute(theApp.m_pADOSet,strQuery);
此时用语句:
for (int j=0; j<jCount; j++)
{
……………………
theApp.m_pADOSet->MoveNext();
}
已经移到了最后一个记录,这时再执行语句:
theApp.m_pADOSet->MoveNext(); 就会出错(应该是出现内存读或写无效)
解决办法是使用两个记录集变量。
2.MOVELAST以后再MOVENEXT肯定要出错
//满足 班级 = ‘00812’的记录有几条
theApp.ADOExecute(theApp.m_pADOSet,strQuery);
int iCount = theApp.m_pADOSet->GetRecordCount();
theApp.m_pADOSet->MoveFirst(); for (int i=0; i<iCount; i++)
{
…………
strQuery = "select * from phy_pro where 学号 = ‘00070001’ ";
theApp.ADOExecute(theApp.m_pADOSet,strQuery);'
int jCount = theApp.m_pADOSet->GetRecordCount();
for (int j=0; j<jCount; j++)
{
……………………
theApp.m_pADOSet->MoveNext();
}
theApp.m_pADOSet->MoveNext(); //为什么在这句的时候就不能执行而报错
}可以将第一个theApp.m_pADOSet声明成一个静态变量第二个theApp.m_pADOSet,不能和第一个重命名,声明空间