Public Sub testDatarows() Dim oDt As New DataTable oDt.Columns.Add("Field1", GetType(String)) oDt.Columns.Add("Field2", GetType(String)) oDt.Columns.Add("Field3", GetType(String)) Dim odr As DataRow = oDt.NewRow odr("Field1") = "value 1" odr("Field2") = "value 2" odr("Field3") = "value 3" oDt.Rows.Add(odr) ' will add a new row oDt.ImportRow(odr) ' then change the newly added row oDt.Rows(dt.Rows.Count-1).Items("Field3") = "value 4" For Each odr In oDt.Rows Debug.Print(odr("Field1") & "- " & odr("field2") & "-" & odr("Field3")) Next End Sub~~Bonnie
> Public Sub testDatarows() > Dim oDt As New DataTable > oDt.Columns.Add("Field1", GetType(String)) > oDt.Columns.Add("Field2", GetType(String)) > oDt.Columns.Add("Field3", GetType(String)) > Dim odr As DataRow = oDt.NewRow > odr("Field1") = "value 1" > odr("Field2") = "value 2" > odr("Field3") = "value 3" > oDt.Rows.Add(odr) > odr("Field3") = "value 4" > oDt.Rows.Add(odr) > For Each odr In oDt.Rows > Debug.Print(odr("Field1") & "- " & odr("field2") & "-" & odr("Field3")) > Next > End Sub >>It breaks at the second
>oDt.Rows.Add(odr) >>
> odr = oDt.NewRow >>