为什么程序运行时我点击了btnClearAllStep后数据库的内容被清空了而DataGrid中的内容没更新呢?
Private Sub btnClearAllStep_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClearAllStep.Click        '清除所有步骤前先进行提示
        If MsgBox("您确定要清除所有步骤吗?", MsgBoxStyle.OKCancel + MsgBoxStyle.Question, "清除提示") = MsgBoxResult.OK Then
            If RecordCount("Select * From TestStep") = 0 Then
                MsgBox("当前所有测试步骤数已为0,无法进行删除操作!", MsgBoxStyle.Critical, "清除提示")
            Else
                Dim strSQL As String = "Delete From TestStep"
                Try
                    Dim cmd As New OleDbCommand(strSQL, myCon)
                    If myCon.State = ConnectionState.Closed Then
                        myCon.Open()
                    End If
                    cmd.ExecuteNonQuery()                Catch ex As Exception
                    MsgBox(ex.Message)
                Finally
                    myCon.Close()
                End Try                '在DataGrid中显示更新后的数据()
                DisplayTestStep()            End If
        End If
    End Sub '显示测试步骤
    Private Sub DisplayTestStep()
        Try
            Dim strSQL As String = "Select * From TestStep"
            Dim cmd As New OleDbCommand(strSQL, myCon)
            If myCon.State = ConnectionState.Closed Then
                myCon.Open()
            End If
            myAdapter.SelectCommand = cmd
            myAdapter.Fill(myDataSet, "TestStep")
            datagridTestStep.DataSource = myDataSet.Tables("TestStep")
        Catch ex As Exception
            MsgBox(ex.ToString)
        Finally
            myCon.Close()
        End Try
    End Sub
我在btnClearAllStep函数中加入myAdapter.Update(myDataSet.Tables("TestStep"))和myDataSet.Tables("TestStep").AcceptChanges后也还是这样.