用PutCollect函数,一个字段一个字段的赋值

解决方案 »

  1.   

    你是用ado连接数据库的吗?
    m_pRecordset->AddNew();   
    m_pRecordset->PutCollect("Num",   _variant_t(m_nuber));   
    m_pRecordset->PutCollect("Name",   _variant_t(m_name));   
    m_pRecordset->PutCollect("Sex",   _variant_t(m_sex));   
    m_pRecordset->PutCollect("Grade",   _variant_t(m_Grade));
    ..........   
    m_pRecordset->Update();   
      

  2.   

    是用ADO连的,那这样是不是把值存到数据库里啦,不是查询吧?
      

  3.   

    这个问题很典型,可以用下面这种形式来处理(大部分都是这样)
    CStirng strSql = "select * from table where 1=1 ";
    if(strUserName.GetLength() > 0 )
    {
        strSql += "and 用户名 = '张三';
    }
    ...
    我应该表达出来了
      

  4.   

    strwhere =" where 1=1 " 
    strCondition += "and name = '张三'" 
    strwhere += strCondition;