Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

Re: StackOverflow error and infinite recursion / loops and the MAXRECURSION hint

 

..throws an error I can't understand!

Can anybody help me..

Did you need help understanding the error or how to fix it in this specific situation?

 

I'm just a .Net newbie, but even I know what infinite recursion is (and that it can cause a stack overflow error).

Per this Wikipedia Stack Overflow page:

In software, a stack overflow occurs when too much memory is used on the call stack.

The call stack contains a limited amount of memory, often determined at the start of the program.

When a program attempts to use more space than is available on the call stack

(that is, when it attempts to access memory beyond the call stack's bounds, which is essentially a buffer overflow),

the stack is said to overflow..

 

The most common cause of stack overflow is excessively deep or infinite recursion.

 

If you Google for "MSDN Transact-SQL infinite loop" you came across

this page WITH common_table_expression (Transact-SQL) which says:

To prevent an infinite loop, you can limit the number of recursion levels

allowed for a particular statement by using the MAXRECURSION hint

and a value between 0 and 32,767 in the OPTION clause of the INSERT, UPDATE, DELETE, or SELECT statement.

This lets you control the execution of the statement until you resolve the code problem that is creating the loop.

The MAXRECURSION hint is also documented on this MSDN Query Hints page.

 

Hopefully using this hint will allow you to debug further..

Edited by bokeh
Posted

I am newbie too, ah man, even you know what infinite recursion is, so I must be so stupid!

 

I couldn't understand what did you mean by your post? Remind me to use Google rather than posting here? OK, I'll remember that!

 

I really use the same code somewhere else and it works!

  • Leaders
Posted
Simply put, your function is calling itself (possibly indirectly) over and over again. Open up the call stack window and look at which functions are calling which to figure out why and how your code is calling itself.
[sIGPIC]e[/sIGPIC]
Posted

Please help, I'm driving crazy!

This is the most strange thing I ever seen in .NET!

I cannot find what's the problem and how to solve it!

 

Private Sub SendFAXForm_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
   Select Case RememberCheckBoxX.Checked
       Case False
           Try
               Dim MyConnection As New OleDbConnection(EmailDBString)
               MyConnection.Open()
               Dim MyCommands As New OleDbCommand("DELETE * FROM SendFAX", MyConnection)
               Dim MyReader As OleDbDataReader = MyCommands.ExecuteReader
               MyReader.Close()
               MyConnection.Close()
               Me.Close()
           Catch Exception As Exception
               MessageBoxEx.Show("There is an error resetting data in database." + vbNewLine + Exception.Message, My.Application.Info.AssemblyName, MessageBoxButtons.OK, MessageBoxIcon.Warning)
           End Try
   End Select
End Sub

 

It calls itself again & again!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...