Hi i want to write an dynamic update statement
there for i need to check wether the previous coloumn values were empty. but the code never seems to get into the "if boolean or boolean or boolean or ... "
How should I write it to make it work??
If one of the booleans is true it should go in the if otherwise in the else
Thanks in advance!!!
there for i need to check wether the previous coloumn values were empty. but the code never seems to get into the "if boolean or boolean or boolean or ... "
How should I write it to make it work??
If one of the booleans is true it should go in the if otherwise in the else
Thanks in advance!!!
Code:
strSqlUpdate = "UPDATE [employee2] SET "
If (StrComp(strVoorNaam, strVoorNaamTemp) <> 0) Then
boolUPDVoornaam = true
melding = melding +1
strSqlUpdate = strSqlUpdate & "[VoorNaam] = " & "'" & strVoorNaamTemp & "'"
ElseIf (StrComp(strAchterNaam, strAchterNaamTemp) <> 0) Then
boolUPDAchterNaam = True
melding = melding +1
If boolUPDVoornaam Then
strSqlUpdate = strSqlUpdate & " , [AchterNaam] = " & "'" & strAchterNaamTemp & "'"
Else
strSqlUpdate = strSqlUpdate & " [AchterNaam] = " & "'" & strAchterNaamTemp & "'"
End If
ElseIf (StrComp(strLocation, strLocationTemp) <> 0) Then
boolUPDLocation = True
melding = melding +1
If boolUPDVoornaam Or boolUPDAchterNaam Then
strSqlUpdate = strSqlUpdate & " , [Location] = " & "'" & strLocationTemp & "'"
Else
strSqlUpdate = strSqlUpdate & " [Location] = " & "'" & strLocationTemp & "'"
End If
ElseIf (StrComp(strKostenstelle, strKostenstelleTemp) <> 0) Then
boolUPDKostenstelle = True
melding = melding +1
If boolUPDVoornaam Or boolUPDAchterNaam Or boolUPDLocation Then
strSqlUpdate = strSqlUpdate & " , [Kostenstelle] = " & "'" & strKostenstelleTemp & "'"
Else
strSqlUpdate = strSqlUpdate & " [Kostenstelle] = " & "'" & strKostenstelleTemp & "'"
End If
ElseIf (StrComp(strAbteilung, strAbteilungTemp) <> 0) Then
boolUPDAbteilung = True
melding = melding +1
If boolUPDVoornaam Or boolUPDAchterNaam Or boolUPDLocation Or boolUPDKostenstelle Then
strSqlUpdate = strSqlUpdate & " , [Abteilung] = " & "'" & strAbteilungTemp & "'"
Else
strSqlUpdate = strSqlUpdate & " [Abteilung] = " & "'" & strAbteilungTemp & "'"
End If
ElseIf (StrComp(strDescription, strDescriptionTemp) <> 0) Then
boolUPDDescription = True
melding = melding +1
If boolUPDVoornaam Or boolUPDAchterNaam Or boolUPDLocation Or boolUPDKostenstelle Or boolUPDAbteilung Then
strSqlUpdate = strSqlUpdate & " , [Description] = " & "'" & strDescriptionTemp & "'"
Else
strSqlUpdate = strSqlUpdate & " [Description] = " & "'" & strDescriptionTemp & "'"
End If
Else
'brauchen kein update fus dieses record
End If
If (melding <> 0) Then
strSqlUpdate = strSqlUpdate & " WHERE [Username] = " & "'" & strUsername & "'"
MsgBox strSqlUpdate
iUpdate = iUpdate +1
UpdateCommand.CommandType = 1
UpdateCommand.CommandText = strSqlUpdate
UpdateCommand.Execute
melding = 0
boolUPDVoornaam = False
boolUPDAchterNaam = False
boolUPDLocation = False
boolUPDKostenstelle = False
boolUPDAbteilung = False
boolUPDDescription = False
End If
Else
'nog niet
End If