loop thru controls on form to add to parameter list
Posted on 2004-11-21
I am new to VB.net coming from Visual Foxpro. I am loading a SQL database with a big vb.net web form. I connect to SQL with SQLconnect and and Insert statement executed with ExecuteReader.
I have more than 50 controls on the form and some pretty ugly code that fills the parameters to send to the sQL insert command:
cmd.Parameters.Add("@major6", SqlDbType.Char, 25).Value = Major6Text.Value
for 50 fields is not pretty!
Is there a way to loop thru all controls on my form (they are all server side controls with an id) ?