|
-
Dec 2nd, 2008, 01:37 PM
#1
Thread Starter
Hyperactive Member
[2005] 'System.StackOverflowException'
Good afternoon!
I have been receiving the below exception:
An unhandled exception of type 'System.StackOverflowException' occurred in System.Data.dll
My app has various text boxes that allows a user to enter certain criteria for fields to build a filter property for a datagridview.
Whenever the user enters more than 300 or so items (could be character limit, not sure), the above error occurs when they attempt to receive the records. Or maybe a limit on the amount of records it can return.
I can't seem to Catch the exception, and do the app just closes.
Looking at the 'View Detail' only shows the above exception message.
Any ideas?
Thanks!
Last edited by jeffcravener; Dec 2nd, 2008 at 01:41 PM.
-
Dec 2nd, 2008, 02:51 PM
#2
Re: [2005] 'System.StackOverflowException'
the code i see looks correct.
-
Dec 2nd, 2008, 02:55 PM
#3
Thread Starter
Hyperactive Member
Re: [2005] 'System.StackOverflowException'
Sorry, didn't post the code because it doesn't appear to be a code issue, so much as a DLL issue. Liek some kind of limit. Need to know of a way to catch the error when it is from the DLL.
Here is the code it appears it is happening at (.NET is not pointing to any code when the error occurs, but when commented out, the rest of the code works)
Code:
With dvOrigSRs
.Table = dsCMT.Tables(My.Settings.CMTSTNDRDR).Copy
.RowFilter = TFNFilter
.Sort = CreateSortString()
End With
-
Dec 2nd, 2008, 02:57 PM
#4
Re: [2005] 'System.StackOverflowException'
How does CreateSortString look?
-
Dec 2nd, 2008, 03:04 PM
#5
Thread Starter
Hyperactive Member
Re: [2005] 'System.StackOverflowException'
This is createsortstring:
Code:
Private Function CreateSortString() As String
Dim l As Button
Dim s As String = ""
For Each l In ButtonSorts
If l.Text <> "NS" Then
If l.Text = "S^" Then
s = "ASC"
Else
s = "DESC"
End If
Select Case l.Name
Case "butSortTFN"
s = "[TFN] " & s
Case "butSortMP"
s = "[M/P] " & s
Case "butSortAPPL"
s = "[APPL] " & s
Case "butSortPROD"
s = "[PROD] " & s
Case "butSortCNC"
s = "[CL/NCL] " & s
Case "butSortALTOFF"
s = "[ALT OFF] " & s
Case "butSortIBP"
s = "[IBP] " & s
Case "butSortOBP"
s = "[OBP] " & s
Case "butSortXFER"
s = "[XFER] " & s
End Select
End If
Next
If s = "" Then
s = "[Sequence] " & "ASC"
Else
s = s & ",[Sequence] " & "ASC"
End If
Return s
End Function
But its def not that code, as when i am testing the condition limit, i don't sort any columns.
Here is the code used to create the conditions:
Code:
Private Sub RetrieveResults()
Dim tLU As String = ""
Dim LookUp As String = ""
UpdateStatus("Creating lookup statement", True)
LookUpSub(tLU, "TFN", txtTFNS.Lines)
If tLU <> "" Then LookUp = tLU
LookUpSub(tLU, "M/P", txtMP.Lines)
If tLU <> "" Then
If LookUp = "" Then
LookUp = tLU
Else
LookUp = LookUp & " AND " & tLU
End If
End If
LookUpSub(tLU, "APPL", txtAPP.Lines)
If tLU <> "" Then
If LookUp = "" Then
LookUp = tLU
Else
LookUp = LookUp & " AND " & tLU
End If
End If
LookUpSub(tLU, "PROD", txtPROD.Lines)
If tLU <> "" Then
If LookUp = "" Then
LookUp = tLU
Else
LookUp = LookUp & " AND " & tLU
End If
End If
LookUpSub(tLU, "CL/NCL", txtCNC.Lines)
If tLU <> "" Then
If LookUp = "" Then
LookUp = tLU
Else
LookUp = LookUp & " AND " & tLU
End If
End If
LookUpSub(tLU, "ALT OFF", txtALTOFF.Lines)
If tLU <> "" Then
If LookUp = "" Then
LookUp = tLU
Else
LookUp = LookUp & " AND " & tLU
End If
End If
LookUpSub(tLU, "IBP", txtIBPs.Lines)
If tLU <> "" Then
If LookUp = "" Then
LookUp = tLU
Else
LookUp = LookUp & " AND " & tLU
End If
End If
LookUpSub(tLU, "OBP", txtOBPs.Lines)
If tLU <> "" Then
If LookUp = "" Then
LookUp = tLU
Else
LookUp = LookUp & " AND " & tLU
End If
End If
LookUpSub(tLU, "XFER", txtXFERs.Lines)
If tLU <> "" Then
If LookUp = "" Then
LookUp = tLU
Else
LookUp = LookUp & " AND " & tLU
End If
End If
If LookUp = "" Then
MessageBox.Show("You must choose at least one field to filter by. Thanks.", "No Filter Values Selected", MessageBoxButtons.OK, MessageBoxIcon.Information)
UpdateStatus("Ready")
Exit Sub
End If
LoadTFNorDNIS(LookUp)
End Sub
Private Function ConditionCount() As Long
Return txtTFNS.Lines.Length + txtMP.Lines.Length + txtAPP.Lines.Length + _
txtPROD.Lines.Length + txtCNC.Lines.Length + txtALTOFF.Lines.Length + _
txtIBPs.Lines.Length + txtOBPs.Lines.Length + txtXFERs.Lines.Length
End Function
Private Sub LookUpSub(ByRef FilterText As String, ByVal FieldName As String, ByVal TextBoxLines() As String)
Dim i As Integer
FilterText = ""
If TextBoxLines.Length > 0 Then
For i = 0 To TextBoxLines.Length - 1
If FieldName = "TFN" And (TextBoxLines(i) <> "(Blanks)") And (TextBoxLines(i) <> "(No Blanks)") Then TrimTFNChars(TextBoxLines(i))
If FilterText.Contains(TextBoxLines(i)) = False Then
If TextBoxLines(i) = "(Blanks)" Then
If FilterText = "" Then
FilterText = "[" & FieldName & "] IS NULL"
Else
FilterText = FilterText & " OR [" & FieldName & "] IS NULL"
End If
ElseIf TextBoxLines(i) = "(No Blanks)" Then
If FilterText = "" Then
FilterText = "[" & FieldName & "] IS NOT NULL"
Else
FilterText = FilterText & " OR [" & FieldName & "] IS NOT NULL"
End If
Else
If FilterText = "" Then
FilterText = "[" & FieldName & "] = '" & TextBoxLines(i) & "'"
Else
FilterText = FilterText & " OR [" & FieldName & "] = '" & TextBoxLines(i) & "'"
End If
End If
End If
Next
FilterText = "(" & FilterText & ")"
End If
End Sub
Currently using the condition count, against 370, as a workaround to try to avoid the error. But if it is a character based limit, then it could still error out depending on what conditions the user puts.
-
Dec 2nd, 2008, 04:18 PM
#6
Addicted Member
Re: [2005] 'System.StackOverflowException'
And when you hit the stack overflowexception in the debugger, what does the function list look like on the stack trace? (Call Stack window) While the exception is up -> Debug -> Windows -> Call Stack.
-
Dec 2nd, 2008, 06:23 PM
#7
Thread Starter
Hyperactive Member
Re: [2005] 'System.StackOverflowException'
Like this:
> [External Code]
-
Dec 3rd, 2008, 07:20 AM
#8
Addicted Member
Re: [2005] 'System.StackOverflowException'
If all the stack trace says is that, then either your code is not loading into the debugger or the exception is happening in an external dll you are referencing. Check the internal Exception property of the exception perhaps?
-
Dec 3rd, 2008, 10:03 AM
#9
Re: [2005] 'System.StackOverflowException'
Normally, this type of an error occurs when you have created an endless recursive call. Each function call will stick the current state onto the stack and get a little stack space, as needed. Thus, if you end up in an infinite recursion, then each iteration will stick more stuff onto the stack until the stack overflows. I would expect that the same thing is possible with limitted recursion, but I have never seen it. Unfortunately, the problem is being caused externally.
In the original snippet, why are you calling .Copy on the table?
My usual boring signature: Nothing
 
-
Dec 3rd, 2008, 10:19 AM
#10
Thread Starter
Hyperactive Member
Re: [2005] 'System.StackOverflowException'
Calling .Copy because i don't want changes made to the datagridview to actually change the working copy of the database. So i have a copy created for the DV.
But when i place messageboxes before and after the .RowFilter line of code, i only see the first messagebox, then it crashes.
With dvOrigSRs 'dv
.Table = dsCMT.Tables(My.Settings.CMTSTNDRDR).Copy
MessageBox.Show("BOB")
.RowFilter = TFNFilter
MessageBox.Show("FRED")
.Sort = CreateSortString()
End With
So, it is def related to the filter string having too many characters/conditions. But irritating that i can't put a 'catch' to catch it.
I can't see where an endless recursive call would come into play here since it is a SQL liek statement going to the RowFilter property.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|