Using recursion to build up the hierarchy.
This recursion works fine in windows server 2003 + IIS6 but throwing exception in windows server 2008 R2 and IIS 7.0
Here is the code snippet:
Public Sub Expand(ByVal SE_Index As Int64)
Dim row As DataRow
If aryHierarchyData(SE_Index).Visable = True Then
aryHierarchyData(SE_Index).Target_Row = gvCurrent_Row_Number
gvCurrent_Row_Number = gvCurrent_Row_Number + 1
Try
row = dtExpand.NewRow
row("SE_NO") = aryHierarchyData(SE_Index).SE_No
row("Selection_Index") = aryHierarchyData(SE_Index).Selection_Index
**dtExpand.Rows.Add(row)**--->>>throwing error "stackoverflow"
Catch ex As StackOverflowException
If (ex.Message.Contains("Column 'SE_NO, Selection_Index' is constrained to be unique.")) Then
Exit Sub
End If
Catch ex As Exception
Finally
row = Nothing
End Try
' expand this SE's children - first
If aryHierarchyData(SE_Index).Child > 0 Then
Expand(aryHierarchyData(SE_Index).Child)
End If
End If
' expand this SE's Siblings - second
If aryHierarchyData(SE_Index).Sibling > 0 Then
Expand(aryHierarchyData(SE_Index).Sibling)
End If
End Sub
1 Answer