CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
山寨机中的战斗机! 程序优化工程师到底对IT界有没有贡献
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  VC/MFC >  数据库

求助:只读行集问题

楼主up_down(Compiling...work.cxx Linking...wage.lib - 0 error()2005-08-04 11:44:35 在 VC/MFC / 数据库 提问

遇到下列问题,需要同时更新两张表的两个记录,更新时出现只读行集问题。代码如下:  
  void   CBurnView::OnButtonClear()    
  {  
  //   TODO:   Add   your   control   notification   handler   code   here  
  m_btDelList.DeleteAllItems();  
        CBackUpBurnDoc*   pDoc=(CBackUpBurnDoc*)GetDocument();  
  CString   sqls;  
  if(pDoc->m_pimageRecord->GetState()==1)  
  pDoc->m_pimageRecord->Close();  
  sqls="select   images.IMAGE,backupandburn.isclearimage,backupandburn.isburn";  
  sqls+="   from   images,backupandburn";  
  sqls+="   where     images.instanceuid=backupandburn.instanceuid   and   ";  
                    sqls+="     backupandburn.isburn='已刻录'     ";  
  _variant_t   varCheck;  
  varCheck=_variant_t("");  
   
  try  
  {  
    pDoc->m_pConnection->BeginTrans();  
                    pDoc->m_pimageRecord->Open(sqls.AllocSysString(),_variant_t((IDispatch*)pDoc-                                     >m_pConnection,true),adOpenDynamic,adLockPessimistic,adCmdText);  
  while(!pDoc->m_pimageRecord->adoEOF)  
  {  
    pDoc->m_pimageRecord->Fields->GetItem("image")->AppendChunk(varCheck);  
                                          //这一句没问题    
  pDoc->m_pimageRecord->PutCollect("isclearimag",_variant_t("已清除"));//1到此遇到只读行集问题,catch提示对话框:ROW-00009:不能更新只读rowset中的行。  
             
  pDoc->m_pimageRecord->Update();  
          pDoc->m_pimageRecord->MoveNext();  
  }  
  }  
   
   
  catch(_com_error   e)  
  {  
  pDoc->m_pConnection->RollbackTrans();  
  MessageBox(e.Description());  
  return;  
  }  
  pDoc->m_pConnection->CommitTrans();  
  m_btQuery.EnableWindow(true);  
  m_btDel.EnableWindow(false);  
   
  }  
  谁能解决,分不是问题。还可以加。 问题点数:100、回复次数:10Top

1 楼happyparrot(快乐鹦鹉)回复于 2005-08-04 11:51:34 得分 50

将那两句更新的语句交换一下试试看呢。Top

2 楼up_down(Compiling...work.cxx Linking...wage.lib - 0 error()回复于 2005-08-04 12:00:31 得分 0

非常感谢,已交换,但问题依旧。期待中......Top

3 楼dirdirdir3(风)回复于 2005-08-04 12:31:43 得分 20

要先Edit()吧。Top

4 楼happyparrot(快乐鹦鹉)回复于 2005-08-04 12:32:24 得分 0

交换以后,是哪句错误了?Top

5 楼up_down(Compiling...work.cxx Linking...wage.lib - 0 error()回复于 2005-08-04 12:57:36 得分 0

happyparrot(为何我买彩票从来不中奖?没钱怎么办阿?)   (   )   信誉:150    
  交换以后,是哪句错误了?  
  回答:运行到pDoc->m_pimageRecord->PutCollect("isclearimag",_variant_t("已清除"));//1到此遇到只读行集问题,catch提示对话框:ROW-00009:不能更新只读rowset中的行。  
  直接跳到catch(_com_error   e)  
  {  
  pDoc->m_pConnection->RollbackTrans();  
  MessageBox(e.Description());  
  return;  
  }  
  dirdirdir3(风)   (   )   信誉:100    
  没有Edit()成员函数  
  Top

6 楼happyparrot(快乐鹦鹉)回复于 2005-08-04 13:06:14 得分 0

Open记录集时,将adLockPessimistic改为adLockOptimistic如何?Top

7 楼up_down(Compiling...work.cxx Linking...wage.lib - 0 error()回复于 2005-08-04 14:11:18 得分 0

多谢各位支持!目前已确定是SQL语句的问题,将SQL改为select   *   from   backupandburn,注释掉  
  pDoc->m_pimageRecord->Fields->GetItem("image")->AppendChunk(varCheck);调试通过或将SQL  
  改为select   *   from   images,注释掉pDoc->m_pimageRecord->PutCollect("isclearimag",_variant_t("已清除"));也可以通过。但两个表应同步,不能叫我用两个Recordset吧。请各位继续支持。  
  THANKS.  
  Top

8 楼handsomerun(毛毛)回复于 2005-08-04 14:38:56 得分 30

那么用inner   join做联合查询试试吧  
   
   
  select   images.IMAGE,backupandburn.isclearimage,backupandburn.isburn   from   images   inner   join  
    backupandburn   on   images.instanceuid=backupandburn.instanceuid     where   ........  
   
   
  不知道我的inner   join有没有写错,试试吧  
  Top

9 楼up_down(Compiling...work.cxx Linking...wage.lib - 0 error()回复于 2005-08-04 16:14:51 得分 0

happyparrot(为何我买彩票从来不中奖?没钱怎么办阿?)   (   )   信誉:150    
  Open记录集时,将adLockPessimistic改为adLockOptimistic如何?  
  改为了乐观锁定方式,adLockOptimistic或adLockBatchOptimistic(乐观分批更新),情况如下,  
  e       {E_FAIL}  
  387:                             pDoc->m_pimageRecord->PutCollect("isclearimag",_variant_t("已清除"));  
  00415DB5       push                 offset   string   "isclearimag"   (00436a28)  
  00415DBA       lea                   ecx,[ebp-8Ch]  
  00415DC0       call                 @ILT+875(_variant_t::_variant_t)   (00401370)  
  00415DC5       mov                   dword   ptr   [ebp-0D4h],eax  
  00415DCB       mov                   byte   ptr   [ebp-4],6  
  00415DCF       push                 offset   string   "select   *   from   images"   (00433e78)  
  00415DD4       lea                   ecx,[ebp-7Ch]  
  00415DD7       call                 @ILT+875(_variant_t::_variant_t)   (00401370)  
  00415DDC       mov                   dword   ptr   [ebp-0D8h],eax  
  00415DE2       mov                   ecx,dword   ptr   [ebp-0D8h]  
  00415DE8       mov                   dword   ptr   [ebp-0DCh],ecx  
  00415DEE       mov                   byte   ptr   [ebp-4],7  
  00415DF2       mov                   ecx,dword   ptr   [ebp-18h]  
  00415DF5       add                   ecx,60h  
  00415DF8       call                 @ILT+955(_com_ptr_t<_com_IIID<_Recordset,&_GUID_00000556_0000_0010_8000_00aa006d2ea4>   >:  
  00415DFD       mov                   dword   ptr   [ebp-0E0h],eax  
  00415E03       mov                   edx,dword   ptr   [ebp-0DCh]  
  00415E09       push                 edx  
  00415E0A       lea                   eax,[ebp-8Ch]  
  00415E10       push                 eax  
  00415E11       mov                   ecx,dword   ptr   [ebp-0E0h]  
  00415E17       call                 @ILT+1460(Recordset15::PutCollect)   (004015b9)  
  00415E1C       mov                   byte   ptr   [ebp-4],6  
  00415E20       lea                   ecx,[ebp-7Ch]  
  00415E23       call                 @ILT+1000(_variant_t::~_variant_t)   (004013ed)  
  00415E28       mov                   byte   ptr   [ebp-4],3  
  00415E2C       lea                   ecx,[ebp-8Ch]  
  00415E32       call                 @ILT+1000(_variant_t::~_variant_t)   (004013ed)  
  388:                             pDoc->m_pimageRecord->Fields->GetItem("dicomimage")->AppendChunk(varCheck);  
  00415E37       push                 offset   string   "dicomimage"   (004375f0)  
  00415E3C       lea                   ecx,[ebp-0A0h]  
  00415E42       call                 @ILT+875(_variant_t::_variant_t)   (00401370)  
  00415E47       mov                   dword   ptr   [ebp-0E4h],eax  
  00415E4D       mov                   byte   ptr   [ebp-4],8  
  00415E51       mov                   ecx,dword   ptr   [ebp-18h]  
  00415E54       add                   ecx,60h  
  00415E57       call                 @ILT+955(_com_ptr_t<_com_IIID<_Recordset,&_GUID_00000556_0000_0010_8000_00aa006d2ea4>   >:  
  00415E5C       mov                   dword   ptr   [ebp-0E8h],eax  
  00415E62       lea                   ecx,[ebp-90h]  
  00415E68       push                 ecx  
  00415E69       mov                   ecx,dword   ptr   [ebp-0E8h]  
  00415E6F       call                 @ILT+820(Recordset15::GetFields)   (00401339)  
  00415E74       mov                   dword   ptr   [ebp-0ECh],eax  
  00415E7A       mov                   edx,dword   ptr   [ebp-0ECh]  
  00415E80       mov                   dword   ptr   [ebp-0F0h],edx  
  00415E86       mov                   byte   ptr   [ebp-4],9  
  00415E8A       mov                   ecx,dword   ptr   [ebp-0F0h]  
  00415E90       call                 @ILT+90(_com_ptr_t<_com_IIID<Fields,&_GUID_00000564_0000_0010_8000_00aa006d2ea4>   >::oper  
  00415E95       mov                   dword   ptr   [ebp-0F4h],eax  
  00415E9B       lea                   eax,[ebp-0A0h]  
  00415EA1       push                 eax  
  00415EA2       lea                   ecx,[ebp-0A4h]  
  00415EA8       push                 ecx  
  00415EA9       mov                   ecx,dword   ptr   [ebp-0F4h]  
  00415EAF       call                 @ILT+1370(Fields15::GetItem)   (0040155f)  
  00415EB4       mov                   dword   ptr   [ebp-0F8h],eax  
  00415EBA       mov                   edx,dword   ptr   [ebp-0F8h]  
  00415EC0       mov                   dword   ptr   [ebp-0FCh],edx  
  00415EC6       mov                   byte   ptr   [ebp-4],0Ah  
  00415ECA       mov                   ecx,dword   ptr   [ebp-0FCh]  
  00415ED0       call                 @ILT+1595(_com_ptr_t<_com_IIID<Field,&_GUID_00000569_0000_0010_8000_00aa006d2ea4>   >::ope  
  00415ED5       mov                   dword   ptr   [ebp-100h],eax  
  00415EDB       lea                   eax,[ebp-2Ch]  
  00415EDE       push                 eax  
  00415EDF       mov                   ecx,dword   ptr   [ebp-100h]  
  00415EE5       call                 @ILT+2040(Field20::AppendChunk)   (004017fd)  
  00415EEA       mov                   byte   ptr   [ebp-4],9  
  00415EEE       lea                   ecx,[ebp-0A4h]  
  00415EF4       call                 @ILT+995(_com_ptr_t<_com_IIID<Field,&_GUID_00000569_0000_0010_8000_00aa006d2ea4>   >::~_co  
  00415EF9       mov                   byte   ptr   [ebp-4],8  
  00415EFD       lea                   ecx,[ebp-90h]  
  00415F03       call                 @ILT+1565(_com_ptr_t<_com_IIID<Fields,&_GUID_00000564_0000_0010_8000_00aa006d2ea4>   >::~_  
  00415F08       mov                   byte   ptr   [ebp-4],3  
  00415F0C       lea                   ecx,[ebp-0A0h]  
  00415F12       call                 @ILT+1000(_variant_t::~_variant_t)   (004013ed)  
  389:                             pDoc->m_pimageRecord->Update();  
  00415F17       mov                   ecx,dword   ptr   [ebp-18h]  
  00415F1A       add                   ecx,60h  
  00415F1D       call                 @ILT+955(_com_ptr_t<_com_IIID<_Recordset,&_GUID_00000556_0000_0010_8000_00aa006d2ea4>   >:  
  00415F22       mov                   dword   ptr   [ebp-104h],eax  
  00415F28       push                 offset   vtMissing   (0043baa8)  
  00415F2D       push                 offset   vtMissing   (0043baa8)  
  00415F32       mov                   ecx,dword   ptr   [ebp-104h]  
  00415F38       call                 @ILT+415(Recordset15::Update)   (004011a4)  
  390:                             pDoc->m_pimageRecord->MoveNext();  
  00415F3D       mov                   ecx,dword   ptr   [ebp-18h]  
  00415F40       add                   ecx,60h  
  00415F43       call                 @ILT+955(_com_ptr_t<_com_IIID<_Recordset,&_GUID_00000556_0000_0010_8000_00aa006d2ea4>   >:  
  00415F48       mov                   dword   ptr   [ebp-108h],eax  
  00415F4E       mov                   ecx,dword   ptr   [ebp-108h]  
  00415F54       call                 @ILT+535(Recordset15::MoveNext)   (0040121c)  
  391:                     }  
  00415F59       jmp                   CBurnView::OnButtonClear+1C3h   (00415d83)  
  392:             }  
  393:  
  394:  
  395:             catch(_com_error   e)  
  00415F5E       jmp                   $L94098+1Dh   (00415ff4)  
  __catch$?OnButtonClear@CBurnView@@IAEXXZ$0:  
  00415F63       mov                   byte   ptr   [ebp-4],0Ch  
  396:             {  
  397:                     pDoc->m_pConnection->RollbackTrans();  
  00415F67       mov                   ecx,dword   ptr   [ebp-18h]  
  00415F6A       add                   ecx,54h  
  00415F6D       call                 @ILT+830(_com_ptr_t<_com_IIID<_Connection,&_GUID_00000550_0000_0010_8000_00aa006d2ea4>   >  
  00415F72       mov                   ecx,eax  
  00415F74       call                 @ILT+1265(Connection15::RollbackTrans)   (004014f6)  
  398:                     MessageBox(e.Description());  
  00415F79       lea                   ecx,[ebp-0A8h]  
  00415F7F       push                 ecx  
  00415F80       lea                   ecx,[e]  
  00415F83       call                 @ILT+1965(_com_error::Description)   (004017b2)  
  00415F88       mov                   dword   ptr   [ebp-10Ch],eax  
  00415F8E       mov                   edx,dword   ptr   [ebp-10Ch]  
  00415F94       mov                   dword   ptr   [ebp-110h],edx  
  00415F9A       mov                   byte   ptr   [ebp-4],0Dh  
  00415F9E       push                 0  
  00415FA0       push                 0  
  00415FA2       mov                   ecx,dword   ptr   [ebp-110h]  
  00415FA8       call                 @ILT+925(_bstr_t::operator   char   const   *)   (004013a2)  
  00415FAD       push                 eax  
  00415FAE       mov                   ecx,dword   ptr   [ebp-14h]  
  00415FB1       call                 CWnd::MessageBoxA   (0041b06e)  
  00415FB6       mov                   byte   ptr   [ebp-4],0Ch  
  00415FBA       lea                   ecx,[ebp-0A8h]  
  00415FC0       call                 @ILT+1660(_bstr_t::~_bstr_t)   (00401681)  
  399:                     return;  
   
  Top

10 楼up_down(Compiling...work.cxx Linking...wage.lib - 0 error()回复于 2005-08-04 17:37:19 得分 0

谢谢楼上各位,问题已解决。非常不好意思,开始以为SQL语句不对,结果用PL/SQL执行,语句没错。  
  最后解决的方法是用put_Collect函数执行通过。分已给出,如上。Top

相关问题

  • "记录集是只读"?
  • @记录集只读问题
  • 关于记录集只读问题
  • ?老是提示记录集为只读?!!
  • 记录集为只读的问题
  • 200分,搜集行业英文错读现象。
  • 如何对DataSet数据集进行分页读取数据
  • 数何只读取第10行到第20行的数据?
  • 怎么样利用InputStream 一行一行的读取文件 每行只读取前几个字节啊!!!!
  • 无法定义行集定位,一些值在最后读取时已改变

关键词

  • 语句
  • pimagerecord
  • ilt
  • ebp
  • backupandburn
  • pdoc
  • ecx
  • dword ptr
  • isclearimag
  • mov

得分解答快速导航

  • 帖主:up_down
  • happyparrot
  • dirdirdir3
  • handsomerun

相关链接

  • Visual C++类图书
  • Visual C++类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo