更新查询每次将列值减少2

时间:2016-05-09 14:21:59

标签: sql vb.net

这里我创建了一个sql语句来更新每次减少一列的列值。但是每当我运行查询时它会减少两个。这可能是什么原因

UPDATE       books
SET          no_of_copies = no_of_copies - 1
WHERE        (title = ?)

这是视觉基本代码

    Private Sub issue_from_listbox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles issue_from_listbox2.Click


               If (Me.Book_studentTableAdapter1.studentBorrowHistory(uniqueId) < 5) Then


                Dim bookID = Me.BooksTableAdapter.getSelectedBookID(ListBox2.SelectedItem)
                Me.Book_studentTableAdapter1.IssueBookToStudent(bookID, uniqueId)
                Me.BooksTableAdapter.updateBookTable(ListBox2.SelectedItem)

                DataGridView2.Rows.Add(ListBox2.SelectedItem)
                DataGridView1.Rows.Clear()



            Else
                MessageBox.Show("your shelf is full")

            End If
        End Sub

1 个答案:

答案 0 :(得分:0)

我怀疑(no_of_copies = no_of_copies - 1)执行相同的工作{{1}}。