Updating UsageTime in SQL Server via Visual Studio

2019-09-21 08:15发布

Image

I want to update the UsageTime when the time ticks per minute, couldn't get the right code.

Private Sub LBLTime_TextChanged(sender As Object, e As EventArgs) Handles LBLTime.TextChanged

    con.ConnectionString = My.Settings.Finals_DBConnectionString
    cmd.Connection = con
    con.Close()
    con.Open()
    cmd.CommandText = "update tbl_transaction set usagetime = @ut, remainingtime = @rt"
    cmd.Parameters.Clear()
    cmd.Parameters.AddWithValue("ut", +1)
    cmd.Parameters.AddWithValue("rt", -1)
    cmd.Parameters cmd.ExecuteNonQuery()
    End With
End Sub

1条回答
淡お忘
2楼-- · 2019-09-21 09:15

try this.

update tbl_transaction set usagetime = usagetime+1 , remainingtime = remainingtime -1 

Also don't see any "where" in your sql. It's not a good practice

查看更多
登录 后发表回答