用ADO.RollTrans(好象是这样写的;)
事务处理你知道吗:::——)
ado.begintrans(开始),ado.commintrans(确认更新)

解决方案 »

  1.   

    我的问题应当是很简单的应用吧?我觉得很典型哦。不用事务处理啊。
    直接解决这个问题可以么?用什么办法?rst.cancel? rst.cancelupdate?
    首先,datagrid会报错,其次rst.editmode还是没有恢复回去。
      

  2.   

    没有办法的,如果你在addnew以后做了诸如修改纪录如 rst("good")="900"
    等等的会改变或影响记录集的操作。那么就没有办法解决。因为记录集在响应这些操作前都会把addnew生成完全的记录。也就是说cancelupdate那些只能够取消上一步操作,也仅此一步操作而已。如果没有办法的话,我个人能力限制认为:只能够使用事务处理了。
      

  3.   

    DataGrid有個BeforeUpdate過程,在裡面進行條件判斷,諸如長度,數字類型等
    錯誤數據設置 Cancel=true 取消添加或更新Private Sub DataGrid1_BeforeUpdate(Cancel As Integer)
    If Me.DataGrid1.Row < 0 Then
        Exit Sub
    End If
    Dim msgTemp As Mymsg
            If Me.DataGrid1.Columns(2).Value = "" Then
                     msgTemp = getErrMsg("02", "0033")
                        MsgBox msgTemp.msgdesc, vbOKOnly, msgTemp.title
                        Me.DataGrid1.Move Me.DataGrid1.Row
                        Me.DataGrid1.Col = CuCol
                        Cancel = True '這裡
                        'InfoRs.CancelBatch  '這個是全部新輸入數據在DataGrid中清空
                        Exit Sub
            End If
    End Sub
      

  4.   

    呵呵,我自己解决了.
    datagrid1.datachanged=false,即可CancelUpdate。
    结帐!