Visual Studio (VB).net FOR Statement
Posted on 2007-07-26
In a Visual Studio (Visual Basic) 2005 app, we "pull" data from a Web Service, display it in a datagrid and then insert it into a SQLCE DB.
We have several FOR statements which iterate properly, we take each value from the FORs and pass them to the DB via the datagrid.
The following FOR however does get the values (maximum of three per service) but always ONLY gives us the last one. We assume that means the other two are being over-written and it isn't "stopping" until the last possible value is obtained.
The FOR is as follows (ShipToLocation is a String Collection, .Item is the DataRow, IntShipLoc1 is the SQLCE):
For Each iss As InternationalShippingServiceOptionsType In _ item.ShippingDetails.InternationalShippingServiceOption
If Not iss.ShipToLocation Is Nothing Then
.Item("IntShipLoc1") = String.Join(", ", iss.ShipToLocation.ToArray())
.Item("IntShipLoc1") = "False"
The FOR statements that do work have a count as follows (Minus 1 to Minus 3 across three FORs :
For int1 = 0 To item.ShippingDetails.InternationalShippingServiceOption.Count - 1
We have tried "tying" the non-working FOR into the count FOR but that doesn't help either.
Any help would be hugely appreciated, we have spent days going round and round in circles !