Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
da.update命令vb.net复制数据_Vb.net_Ms Access_Duplicate Data - Fatal编程技术网

da.update命令vb.net复制数据

da.update命令vb.net复制数据,vb.net,ms-access,duplicate-data,Vb.net,Ms Access,Duplicate Data,我有两段代码。第一个更新名为tbl_Customers的access数据库表中的数据。它工作得很好: Private Sub UpdateRecord() Dim imgLocation As String imgLocation = idPictureBox.ImageLocation Dim cb As New OleDb.OleDbCommandBuilder(da) ds.Tables("tbl_Customers").Rows(inc).Item(

我有两段代码。第一个更新名为tbl_Customers的access数据库表中的数据。它工作得很好:

Private Sub UpdateRecord()

    Dim imgLocation As String
    imgLocation = idPictureBox.ImageLocation

    Dim cb As New OleDb.OleDbCommandBuilder(da)

    ds.Tables("tbl_Customers").Rows(inc).Item(1) = txtFirstName.Text
    ds.Tables("tbl_Customers").Rows(inc).Item(2) = txtSurname.Text
    ds.Tables("tbl_Customers").Rows(inc).Item(3) = imgLocation
    ds.Tables("tbl_Customers").Rows(inc).Item(4) = mtxtPhoneNumber.Text
    ds.Tables("tbl_Customers").Rows(inc).Item(5) = cbReferred.Text
    ds.Tables("tbl_Customers").Rows(inc).Item(6) = custType

    da.Update(ds, "tbl_Customers")

    MessageBox.Show("Data updated", "Update")

    btnCommit.Enabled = False
    btnClear.Enabled = False
    btnAddNew.Enabled = True
    btnupdate.Enabled = True
    btnDelete.Enabled = True
    btnFirst.Enabled = True
    btnLast.Enabled = True
    btnNext.Enabled = True
    btnPrevious.Enabled = True
    btnFind.Enabled = True

End Sub
第二段代码更新一个名为tbl_SalesInventory的access数据库表。这段代码复制了表中的每条记录

Private Sub UpdateItemRecord()

    Dim cb As New OleDb.OleDbCommandBuilder(da10)

    ds10.Tables("tbl_SalesInventory").Rows(incInv).Item(1) = txtItemDescription.Text
    ds10.Tables("tbl_SalesInventory").Rows(incInv).Item(2) = txtItemMin.Text
    ds10.Tables("tbl_SalesInventory").Rows(incInv).Item(3) = txtItemAsk.Text

    Dim SelectedType As Integer = cbSellItemType.SelectedIndex
    Dim Type As Integer = SelectedType + 1
    ds10.Tables("tbl_SalesInventory").Rows(incInv).Item(4) = Type.ToString("D2")

    ds10.Tables("tbl_SalesInventory").Rows(incInv).Item(5) = txtItemCost.Text
    ds10.Tables("tbl_SalesInventory").Rows(incInv).Item(6) = dtpItemPDate.Value

    If lblItemStatusDisplay.Text = "For Sale" Then
        ds10.Tables("tbl_SalesInventory").Rows(incInv).Item(7) = "F"
    ElseIf lblItemStatus.Text = "On Layaway" Then
        ds10.Tables("tbl_SalesInventory").Rows(incInv).Item(7) = "L"
    ElseIf lblItemStatus.Text = "Sold" Then
        ds10.Tables("tbl_SalesInventory").Rows(incInv).Item(7) = "S"
    ElseIf lblItemStatus.Text = "Displayed" Then
        ds10.Tables("tbl_SalesInventory").Rows(incInv).Item(7) = "D"
    ElseIf lblItemStatus.Text = "Scrapped" Then
        ds10.Tables("tbl_SalesInventory").Rows(incInv).Item(7) = "X"
    End If

    Try
        ds10.Tables("tbl_SalesInventory").Rows(incInv).Item(8) = txtDiaMin.Text
    Catch ex As Exception
        ds10.Tables("tbl_SalesInventory").Rows(incInv).Item(8) = ""
    End Try

    Try
        ds10.Tables("tbl_SalesInventory").Rows(incInv).Item(9) = txtDiaValue.Text
    Catch ex As Exception
        ds10.Tables("tbl_SalesInventory").Rows(incInv).Item(9) = ""
    End Try

    ds10.Tables("tbl_SalesInventory").Rows(incInv).Item(10) = txtItemWeight.Text
    ds10.Tables("tbl_SalesInventory").Rows(incInv).Item(11) = lblItemMeasure.Text

    da10.Update(ds10, "tbl_SalesInventory")

    MessageBox.Show("Data updated", "Update")

    RefreshDataset()
    SortDS10()

    btnCommitItem.Enabled = False
    btnClearItem.Enabled = False
    btnAddItem.Enabled = True
    btnUpdateItem.Enabled = True
    btnDeleteItem.Enabled = True
    btnFirstItem.Enabled = True
    btnLastItem.Enabled = True
    btnNextItem.Enabled = True
    btnPreviousItem.Enabled = True
    btnSearchItem.Enabled = True

End Sub
有人能解释一下为什么会发生这种情况吗?感谢您对这个问题的及时回复