i am inserting the value of dynamic controls into the db like so;
Dim ae1 As DropDownList = FindControl("AreasExpertise1")
If (ae1 IsNot Nothing) Then
x.Parameters.AddWithValue("@areasexpertise1", ae1.SelectedValue)
End If
then in my query i have parameters like so;
INSERT INTO [foo] ([etc], [etc], [etc], [areasexpertise1], [areasexpertise2])
VALUES (@etc, @etc, @etc, @areasexpertise1, @areasexpertise2)
When the user fills out the form, they see only areasexpertise1 and have to press a button to dynamically insert another area of expertise...
If they only have 1 area of expertise, the query crashes and says 'must declare variable @areasexpertise2.
Please can you tell me a way to either insert nulls when the parameters are empty, or to ignore them?
Thanks a lot