usvpn Posted December 7, 2012 Posted December 7, 2012 Hi, I use Microsoft Access Database Engine 2010 and my code which I already used it somewhere else throws an error I can't understand! Can anybody help me as it's just a few lines and snapshots are attached? Thanks. Quote
bokeh Posted December 8, 2012 Posted December 8, 2012 (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 December 8, 2012 by bokeh Quote
usvpn Posted December 8, 2012 Author Posted December 8, 2012 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! Quote
Leaders snarfblam Posted December 8, 2012 Leaders Posted December 8, 2012 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. Quote [sIGPIC]e[/sIGPIC]
usvpn Posted December 8, 2012 Author Posted December 8, 2012 Thanks man, this code is inside the Form_Closing event... Quote
usvpn Posted December 8, 2012 Author Posted December 8, 2012 snarfblam thanks, yes Form_Closing is not a good idea... Quote
usvpn Posted December 8, 2012 Author Posted December 8, 2012 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! Quote
Administrators PlausiblyDamp Posted December 8, 2012 Administrators Posted December 8, 2012 If you are in the Form_Closing event then the form is already closing, calling Me.Close() will start closing the form again. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.