急!!!ADO插入多条记录。

hncal 2002-11-30 03:48:48
如果利用RecordSet
的Addnew()
插入多条数据记录上千条。
如:
while(m<1000)
{
m_pRecordset->Open("RTMCall",_variant_t (m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdTable);

m_pRecordset->AddNew();

m_pRecordset->PutCollect("NodeID",(long)(m+1));
m_pRecordset->PutCollect("SessionId",(long)(m*2));
m_pRecordset->PutCollect("InternalCall",(long)m);
m_pRecordset->PutCollect("Direction",(long)m);
vdate=dtTime;
m_pRecordset->PutCollect("StartTime",vdate);
try
{
m_pRecordset->Update();
m_pRecordset->Close();
}
catch(_com_error &ce)
{
CString errstring;
errstring.Format("this is error %s",ce.ErrorMessage());
AfxMessageBox(errstring);
}
m++;
}
执行完后在数据库中是有146条记录。为什么?
...全文
115 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
ZHENG017 2002-11-30
  • 打赏
  • 举报
回复
1.把m_pRecordset->Open("RTMCall",_variant_t (m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdTable); 放在循环之前.
2.可以用_CommandPtr来执行"insert into RTMCall values (?,?,?)";

4,011

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 数据库
社区管理员
  • 数据库
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧