我的 SQL 表中有一个位字段,如果它设置为 0,我需要将其更新为 1。我编写了代码来为每个条目设置字段,但我需要先检查它是否已经为 0,所以我可以记录更改的内容。
这是我已经拥有的:
Public Function Update_User_to_TR(ByVal strUserName As String) As String
    Dim myUserName As String = strUserName.Trim
    Dim myReturn As String
    Try
        Dim sql As New SQL
        Dim strQuery As String
        strQuery = "Update dbo.USERS set user_field_Department_TR = 1 where USER_NAME = '" & myUserName & "'"
        myReturn = sql.SQLUpdateWT(strQuery)
    Catch ex As Exception
        myReturn = ex.ToString
        MsgBox(myReturn)
    End Try
    Return myReturn
End Function