注册 登录
编程论坛 VB.NET论坛

违反并发性: DeleteCommand 影响了预期 1 条记录中的 0 条。大家帮忙看看。在其他模块,通过了啊。

fengxye 发布于 2015-09-17 09:41, 2123 次点击
代码
 Dim StrSQL公路计算行车车速 As String = "select [ID],[路段],[时间昼夜],[初期小车],[初期中车],[初期大车],[中期小车],[中期中车],[中期大车],[远期小车],[远期中车],[远期大车] from [公路计算行车车速]"
        Dim adapterJS_公路计算行车车速 As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter(StrSQL公路计算行车车速, ConnJS)
        Dim cmdBuilder3 As OleDb.OleDbCommandBuilder = New OleDbCommandBuilder(adapterJS_公路计算行车车速)

        Try
            Dim table3 As New DataTable()
            table3 = data.计算数据库.Tables("公路计算行车车速")
            Dim row3 As DataRow

            If table3.Rows.Count > 0 Then
                For I = 0 To table3.Rows.Count - 1
                    row3 = table3.Rows(I)
                    row3.Delete()
                Next I

                Dim updateDS3 As DataSet
                updateDS3 = data.计算数据库.GetChanges()
                If Not updateDS3 Is Nothing Then
                    data.计算数据库.AcceptChanges()
                    adapterJS_公路计算行车车速.Update(updateDS3, "公路计算行车车速")
                    'MsgBox("删除成功!")
                End If

                Me.DataGridView3.DataSource = data.计算数据库.Tables("公路计算行车车速")
                Me.DataGridView3.Refresh()
            End If
        Catch ex As Exception
            MsgBox("数据清除失败,请更新后再转换!" & ex.Message)
        End Try

        ConnJS.Close()
2 回复
#2
fengxye2015-09-17 09:42
设置了主键,自动增加编码
#3
fengxye2015-09-17 09:42
错误后也能把数据删除了。
1