We have this old code from an ASP website that we are moving over to ASP.NET C# - we are trying to make minimal changes to the old pages since it wasn't part of the contract but we need to swap this out to C# since all of the new stuff is in it. I have part of it but not the loop piece.
Old code
For a = 1 to Request.Form("propertyid").CountstrSQL = "Insert into property_assign (assigned_to, propertyid) VALUES ("strSQL = strSQL & "'" & Request.Form("assigned_to") & "',"strSQL = strSQL & "'" & Request.Form("propertyid")(a) & "')"
Not a web guy here but -
Are you missing the count?
Request("propertyid")
or
Request("propertyid").Count
or
Request("propertyid").Count()
something like that maybe
digitalwise
ASKER
Ah yes! That was dumb since i have written tons of code today - don't know why I missed it. So now I get
'char' does not contain a definition for 'propertyid' and no extension method 'propertyid' accepting a first argument of type 'char' could be found (are you missing a using directive or an assembly reference?)
i may need to be 1 for the for loop instead of zero.....
digitalwise
ASKER
BillyDvD - how do I reference the value to save it though? I need the value of each iteration.
William Domenz
for ( int i = 0 ; i < this.Request.Form[ "propertyid" ].Length ; i++ ) { string strSQL = "Insert into property_assign (assigned_to, propertyid) VALUES ('" + this.Request.Form[ "assigned_to" ] + "','" + this.Request.Form[ "propertyid" ][ i ] + "')"; //---| Now use the string..... |--- }It is the [i] now - it was (a)
I just looked at this more closely - this is a comma-delimited list of items - they are longer than one character so the length thing isn't going to work. IT looks like
Asdasd_123123, ASD_54123, FAS_2141...
Do you need to iterate each piece of the comma delimeted list?
I am not sure what you are trying to "get" from this loop.
If you had the input to the loop and the outputs pre code change - then we can reverse engineer this much easier.
digitalwise
ASKER
I need the values from the list because we are creating a record for each of the properties. The code was super simple in VB...
For a = 1 to Request.Form("propertyid").CountstrSQL = "Insert into property_assign (assigned_to, propertyid) VALUES ("strSQL = strSQL & "'" & Request.Form("assigned_to") & "',"strSQL = strSQL & "'" & Request.Form("propertyid")(a) & "')"
Open in new window
instead of
Open in new window
You'll need to do the same with
Open in new window