您的位置:程序门 -> vb -> 控件



vsflexgrid 删除数据时又遇怪问题!请高手赐教!


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


vsflexgrid 删除数据时又遇怪问题!请高手赐教!
发表于:2007-08-07 17:46:40 楼主
private   sub   cmd_del_click()
 
dim   a   as   string
a   =   msgbox( "你确实要删除这记录吗? ",   vbokcancel)
  if   a   =   vbok   then
    with   vsg1
  .removeitem   (vsg1.row)
  .refresh
    end   with
  vsg1.refresh
  adodc1.recordsource   =   "   select     *   from   yhdlb   where   dh     =   ( "   +   vsg1.textmatrix(vsg1.row,   1)   +   ")   "
    if   adodc1.recordset.recordcount   >   0   then
    adodc1.recordset.delete
    adodc1.recordset.update
    command1.enabled   =   true
 
    vsg1.refresh
    set   vsg1.datasource   =   adodc1
     
    end   if
  end   if
 
   
end   sub

代码如上   :数据已被删除,而vsflexgrid里的项目却没有却删除,只有等到重新初始化时才不见了!是不是由于绑定的缘故吗???

发表于:2007-08-08 12:52:411楼 得分:0
.refresh不要用了.
你的操作也反了.你应该先将记录从数据库里删除,再去更新flexgrid.
你现在操作flexgird时,数据还在数据库里呢,所以

发表于:2007-08-08 17:07:512楼 得分:0
经过思考,问题已基本解决!现将代码发布如下
private   sub   command2_click()
vsg1.selectionmode   =   flexselectionbyrow
text1.text   =   vsg1.textmatrix(vsg1.rowsel,   1)
dim   a   as   string
a   =   msgbox( "你确实要删除这记录吗? ",   ,   vbokcancel)
  if   a   =   vbok   then
  with   vsg1
vsg1.removeitem   (vsg1.rowsel)
.refresh
end   with
  'adodc1.recordsource   =   "   select     *   from   yhdlb   where   dh     =   ' "   +   trim(text1.text)   +   " '   "
  'if   adodc1.recordset.recordcount   >   0   then
  adodc1.recordset.find   "dh     =   ' "   +   trim(text1.text)   +   " '   "
  if   adodc1.recordset.eof   =   false   then
adodc1.recordset.delete
  adodc1.recordset.update
  end   if
  command1.enabled   =   true
 
 
  adodc1.recordsource   =   "   select     *   from   yhdlb "
  adodc1.refresh
    set   vsg1.datasource   =   adodc1
    vsg1.refresh
  end   if
 
 
   
end   sub


快速检索

最新资讯
热门点击