我正在尝试使用 VB.Net 更新记录。这是代码。它没有给出任何错误。但是每次我运行这段代码时,我都希望变量newbal
会增加。它不会发生。这意味着更新语句不起作用。任何解决方法?
Dim cmd5 As New OracleCommand
cmd5.Connection = conn
cmd5.CommandText = "SELECT * FROM d009022 WHERE prdacctid = :custid AND lbrcode = :lbrcode"
cmd5.Prepare()
cmd5.Parameters.Add(":custid", customernumber)
cmd5.Parameters.Add(":lbrcode", lbr)
Try
Dim drs As OracleDataReader = cmd5.ExecuteReader()
drs.Read()
Dim oldbal As Decimal = drs.Item("SHDCLRBALFCY")
Dim newbal As Integer = CInt(oldbal) + CInt(amount)
Dim cmd6 As New OracleCommand
cmd6.Connection = conn
cmd6.CommandText = "UPDATE d009022 SET shdclrbalfcy = :newbal WHERE prdacctid = :custnum AND lbrcode = :lbr"
cmd6.Prepare()
cmd6.BindByName = True
cmd6.Parameters.Add(":newbal", newbal)
cmd6.Parameters.Add(":custnum", customernumber)
cmd6.Parameters.Add(":lbr", lbr)
cmd6.ExecuteNonQuery()