注册 登录
编程论坛 VC++/MFC

求大神,怎样把II JJ KK 传入到sql语句中呢???

weichaoheng 发布于 2013-06-14 17:39, 478 次点击
void CEx2View::OnButton2()
{
    // TODO: Add your control notification handler code here
    UpdateData(true);
    int II=2;  int JJ=2;  int KK=2;
    long m_1,m_2,m_3,m_00=0;

    CString str;               
    //str.Format("select * from frp3 where k='%s' ",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' ",II,JJ,KK);
               
                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_00=m_1+m_2+m_3;
                }
                catch(_com_error*e)
                {
                    AfxMessageBox(e->ErrorMessage());
                }

                m_0=m_00;   
                UpdateData(false);
}
1 回复
1