I was previously taught today how to set parameters in a SQL query in .NET in this answer (click).
Using parameters with values are fine, but when I try to set a field in the database to null I'm unsuccessful. Either the method thinks I am not setting a valid parameter or not specifying a parameter.
e.g.
Dim dc As New SqlCommand("UPDATE Activities SET [Limit] = @Limit WHERE [Activity] = @Activity", cn)
If actLimit.ToLower() = "unlimited" Then
' It's not nulling :(
dc.Parameters.Add(New SqlParameter("Limit", Nothing))
Else
dc.Parameters.Add(New SqlParameter("Limit", ProtectAgainstXSS(actLimit)))
End If
Is there something I'm missing? Am I doing it wrong?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…