void CEx2View::OnButijk()
{
// TODO: Add your control notification handler code hereUpdateData(true);int II=m_II; int JJ=m_JJ; int KK=m_KK;
long m_1,m_2,m_3=0;
for(int I=1;I<=II;I++)
{
for(int J=1;J<=JJ;J++)
{
for(int K=1;K<=KK;K++)
{
CString str;
//str.Format("select * from frp3 where k='%s' ",K);
//str.Format("select * from frp3 where i=I and j=J and k=K");
//str.Format("select * from frp3 where i='%d' and j='%d' and k='%d' ",I,J,K);
try
{
_variant_t RecordsAffected;
m_pRecordset =m_pConnection->Execute((_bstr_t)str,&RecordsAffected,adCmdText);
_variant_t vCount; vCount = m_pRecordset->GetCollect("Cijkf");
m_1=vCount.lVal;
vCount = m_pRecordset->GetCollect("Cijkrp");
m_2=vCount.lVal;
vCount = m_pRecordset->GetCollect("Cijkcl");
m_3=vCount.lVal; m_0=m_1+m_2+m_3;
}
catch(_com_error*e)
{
AfxMessageBox(e->ErrorMessage());
}
}
}
} UpdateData(false);}
{
// TODO: Add your control notification handler code hereUpdateData(true);int II=m_II; int JJ=m_JJ; int KK=m_KK;
long m_1,m_2,m_3=0;
for(int I=1;I<=II;I++)
{
for(int J=1;J<=JJ;J++)
{
for(int K=1;K<=KK;K++)
{
CString str;
//str.Format("select * from frp3 where k='%s' ",K);
//str.Format("select * from frp3 where i=I and j=J and k=K");
//str.Format("select * from frp3 where i='%d' and j='%d' and k='%d' ",I,J,K);
try
{
_variant_t RecordsAffected;
m_pRecordset =m_pConnection->Execute((_bstr_t)str,&RecordsAffected,adCmdText);
_variant_t vCount; vCount = m_pRecordset->GetCollect("Cijkf");
m_1=vCount.lVal;
vCount = m_pRecordset->GetCollect("Cijkrp");
m_2=vCount.lVal;
vCount = m_pRecordset->GetCollect("Cijkcl");
m_3=vCount.lVal; m_0=m_1+m_2+m_3;
}
catch(_com_error*e)
{
AfxMessageBox(e->ErrorMessage());
}
}
}
} UpdateData(false);}
str.Format("select * from frp3 where i=2 and j=2 and k=2");可以运行str.Format("select * from frp3 where i='%d' and j='%d' and k='%d' ",I,J,K);不能运行
str.Format("select * from frp3 where i=%d and j=%d and k=%d ",I,J,K);
str.Format("select * from frp3 where i=2 and j=2 and k=2");可以运行str.Format("select * from frp3 where i='%d' and j='%d' and k='%d' ",I,J,K);不能运行你多加了单引号,没看明白?把单引号去掉啊
str.Format("select * from frp3 where i=2 and j=2 and k=2");可以运行str.Format("select * from frp3 where i='%d' and j='%d' and k='%d' ",I,J,K);不能运行你多加了单引号,没看明白?把单引号去掉啊去掉了,可以运行了,谢谢啦