You absolutely should be using parameters to insert values into SQL code, as has already been suggested. That said, any time you want to perform multiple concatenations like this, it is always best to use String.Format
or string interpolation. You made this mistake because using lots of concatenation operators (&) makes your code hard to read. If you had used String.Format
or string interpolation then it would have been impossible to put that And
operator in the VB code instead of the SQL code:
String.Format("UPDATE Tbl_User_Privilges_Forms SET [F_View] = {0}, [F_Edit] = {1} WHERE [FormID] = {2} AND [UserID] = {3}",
rw.Cells(4).Value,
rw.Cells(5).Value,
rw.Cells(2).Value,
H)
or:
$"UPDATE Tbl_User_Privilges_Forms SET [F_View] = {rw.Cells(4).Value}, [F_Edit] = {rw.Cells(5).Value} WHERE [FormID] = {rw.Cells(2).Value} AND [UserID] = {H}"
Note that this does solve your issue but it's not a direct answer to the question of what you did wrong. Danski has provided an explanation of that so I haven't repeated it here. I would have posted this information in a comment but the volume of code I wanted to provide made that impractical.