如何在每次读取时从行添加值

时间:2016-02-15 13:30:56

标签: mysql vb.net increment

我希望每次读者阅读时都会将金额列的值添加到lblamount。但是,它只会替换值而不是添加它。

MySqlConn.Open()
        Dim query As String
        Dim reader As MySqlDataReader
        query = "SELECT * FROM services WHERE Service_Name ='" & txtURThirdMolar.Text & "'"
        cmd = New MySqlCommand(query, MySqlConn)
        reader = cmd.ExecuteReader

        If reader.Read Then
            Dim amnt As Integer
            amnt = reader.Item("Amount")
            lblAmount.Text = +amnt
        End If
        MySqlConn.Close()

1 个答案:

答案 0 :(得分:0)

amnt = reader.Item("Amount")替换为amnt = amnt + reader.Item("Amount") .....您也可以将其替换为amnt += reader.Item("Amount"),这是您的选择......