S Subatanx86 Member Licensed User Sep 9, 2021 #1 Is it possible to use the And operator to set two conditions for WhereFields that must be true to update a DBUtils record? I'm sure I'm wording this poorly. Below is an example of what I want to do, but it obviously doesn't work. B4X: Dim WhereFields As Map WhereFields.Initialize WhereFields.Put("Badge", txtBadge.text) AND WhereFields.Put("Status", "out") DBUtils.UpdateRecord(sql1, "People", "DateOut", DateTime.Date(DateTime.Now), WhereFields)
Is it possible to use the And operator to set two conditions for WhereFields that must be true to update a DBUtils record? I'm sure I'm wording this poorly. Below is an example of what I want to do, but it obviously doesn't work. B4X: Dim WhereFields As Map WhereFields.Initialize WhereFields.Put("Badge", txtBadge.text) AND WhereFields.Put("Status", "out") DBUtils.UpdateRecord(sql1, "People", "DateOut", DateTime.Date(DateTime.Now), WhereFields)
OliverA Expert Licensed User Longtime User Sep 9, 2021 #2 The WhereFields are ANDed Code: Dim WhereFields As Map WhereFields.Initialize WhereFields.Put("Badge", txtBadge.text) WhereFields.Put("Status", "out") DBUtils.UpdateRecord(sql1, "People", "DateOut", DateTime.Date(DateTime.Now), WhereFields) The update will only happen on records where Badge = txtBadge.text AND Status = "out" Upvote 1
The WhereFields are ANDed Code: Dim WhereFields As Map WhereFields.Initialize WhereFields.Put("Badge", txtBadge.text) WhereFields.Put("Status", "out") DBUtils.UpdateRecord(sql1, "People", "DateOut", DateTime.Date(DateTime.Now), WhereFields) The update will only happen on records where Badge = txtBadge.text AND Status = "out"
S Subatanx86 Member Licensed User Sep 9, 2021 #3 OliverA said: The WhereFields are ANDed Code: Dim WhereFields As Map WhereFields.Initialize WhereFields.Put("Badge", txtBadge.text) WhereFields.Put("Status", "out") DBUtils.UpdateRecord(sql1, "People", "DateOut", DateTime.Date(DateTime.Now), WhereFields) The update will only happen on records where Badge = txtBadge.text AND Status = "out" Click to expand... Interesting I'm not getting the results I'm expecting. I'll look to see if I made an error somewhere else. Upvote 0
OliverA said: The WhereFields are ANDed Code: Dim WhereFields As Map WhereFields.Initialize WhereFields.Put("Badge", txtBadge.text) WhereFields.Put("Status", "out") DBUtils.UpdateRecord(sql1, "People", "DateOut", DateTime.Date(DateTime.Now), WhereFields) The update will only happen on records where Badge = txtBadge.text AND Status = "out" Click to expand... Interesting I'm not getting the results I'm expecting. I'll look to see if I made an error somewhere else.
S Subatanx86 Member Licensed User Sep 9, 2021 #4 Confirmed I made a dumb typo. It does work. Thanks for the help. Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Sep 10, 2021 #5 Tip: Code: DBUtils.UpdateRecord(sql1, "People", "DateOut", DateTime.Date(DateTime.Now), CreateMap("Badge": txtBadge.Text, "Status": "out")) Upvote 0
Tip: Code: DBUtils.UpdateRecord(sql1, "People", "DateOut", DateTime.Date(DateTime.Now), CreateMap("Badge": txtBadge.Text, "Status": "out"))