基本点如题
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++菜鸟
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++菜鸟
解决方案 »
- 有一个usb的无线网卡,请问如何编程实现抓取到经过无线网卡上的数据包, windows环境?
- UDP的recvfrom接收问题
- 【Help】如何获取一个窗体的图标?
- 为什么我这段代码,BoundsChecker老是报我没有选回旧资源?
- 作业碰到这个问题,如何回答
- 关于radio?(超难,大家帮忙啊!!)
- AfxBeginThread创建线程问题
- 为什么用c代码组成的console程序没有内存泄漏,而写成dll后就有泄漏了那
- 在CRecordSet中能插入的最大字符串有多长?求教高手了!
- 关于VC++的问题,99分全部奉上!!!
- 两个矩形相交问题
- VC里面,使用xml,可以连续载入两个不同的XML文件吗?我的怎么出错?
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 属性检查任何数据冲突并加以解决