基本点如题
hr = m_pConnection->Open(_bstr_t(m_connectionStr),"","",adEditNone);
////
CString   sqlquery;
sqlquery.Format("select * from scores,students where students.studentid =scores.stdnumber and scores.subjectid=%d",subjectid);
_variant_t sql=sqlquery;
m_pRecordset.CreateInstance("ADODB.Recordset");
m_pRecordset->Open(sql,_variant_t((IDispatch*)m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText);
return m_pRecordset;
/////
m_pRecordset->AddNew();
m_pRecordset->PutCollect("studentname",vstudentname);
m_pRecordset->PutCollect("studentid",vstudentnumber);
m_pRecordset->PutCollect("scorecontent",vscore);
m_pRecordset->Update();执行到update就不行了,我的目的是只将记录放到记录集中,上面打开连接的时候用adEditNone不知道对不对,看别人说这样,用update不会直接到数据库了,要用到updatebatch();
大虾帮帮,VC++菜鸟

解决方案 »

  1.   

    一般我不会对多表用m_pRecordset->Update(); 直接用SQL的update语句。如果一定要用,就用view吧
      

  2.   

    m_pRecordset->AddNew(); 
    m_pRecordset->PutCollect("studentname",vstudentname); 
    m_pRecordset->PutCollect("studentid",vstudentnumber); 
    m_pRecordset->PutCollect("scorecontent",vscore); 
    m_pRecordset->Update(); 
    你这样也对的吧。recordset有两种更新模式。
    立即更新模式, 条用updata方法,。
    批更新模式, 提供者缓存多个更改并只在条用updatabatch方法时将其写入基本数据源
    Recordset 对象可支持两类更新:立即更新和批更新。使用立即更新,一旦调用 Update 方法,对数据的所有更改将被立即写入基本数据源。也可以使用 AddNew 和 Update 方法将值的数组作为参数传递,同时更新记录的若干字段。如果提供者支持批更新,可以使提供者将多个记录的更改存入缓存,然后使用 UpdateBatch 方法在单个调用中将它们传送给数据库。这种情况应用于使用 AddNew、Update 和 Delete 方法所做的更改。调用 UpdateBatch 方法后,可以使用 Status 属性检查任何数据冲突并加以解决
      

  3.   

    不知道怎么回复...上面的我也看到过,当时以为对ACCESS可以设置模式,取得批更新的方式,不过后来看MSDN里面好像说过一般对ACCESS都是直接更新的方式,没别的法了