运行到.Refresh时出现Operation is not allowed when the object is closed 错误
但是数据依然可以删掉。帮忙看一下要怎么改!谢谢    If MsgBox("確定刪除記錄? ,  vbQuestion + vbYesNo + vbDefaultButton2) = vbYes Then
    With Adodc1
          
        .CursorType = adOpenDynamic
        .CommandType = adCmdText          
        .RecordSource = "delete from data where 編號 = " & Me.VSFlexGrid1.TextMatrix(Me.VSFlexGrid1.RowSel, 42) & " " 
         .Refresh
        
   End With
       MsgBox "數據刪除成功!", vbInformation
    Else
        MsgBox "數據刪除操作被取消!", vbExclamation
    End If

解决方案 »

  1.   


    If MsgBox("確定刪除記錄? , vbQuestion + vbYesNo + vbDefaultButton2) = vbYes Then
      With Adodc1
       
      .CursorType = adOpenDynamic
      .CommandType = adCmdText  
      .Recordset.ActiveConnection.Execute = "delete from data where 編號 = " & Me.VSFlexGrid1.TextMatrix(Me.VSFlexGrid1.RowSel, 42) & " " 
      End With
      MsgBox "數據刪除成功!", vbInformation
      Else
      MsgBox "數據刪除操作被取消!", vbExclamation
      End If
      

  2.   

    delete语句不返回记录集,你refresh当然有问题了,去掉.refresh
      

  3.   

    怎样连接ADODC与access数据库,,楼主