本文介绍了system.data.dll中发生了'system.stackoverflowexception'类型的未处理异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我想从关闭按钮关闭窗体后插入值,我用了,这个代码但是我有这个例外。 i知道什么是这个例外但是怎么样我使这段代码工作, private void FRM_Main_FormClosing(对象发送者,FormClosingEventArgs e) s =插入LoginAndOutDate(user_name,Logout_Date); s = s +values(@ user_name,CURRENT_TIMESTAMP); if(con .State == ConnectionState.Closed) con.Open(); sCommand = new SqlCommand(s,con); sCommand.Parameters.AddWithValue(@ user_name,textBox_ForName.Text); sCommand.ExecuteNonQuery(); if(con.State == ConnectionState.Open) con.Close(); this.Close(); b $ b this.RefToFormLogin.Show(); } 我的尝试: i当我从关闭按钮关闭表格时,值插入..i want insert value after close the form from close button , i used , this code but i have this exception.i know what is mean this exception but how i make this code work,private void FRM_Main_FormClosing(object sender, FormClosingEventArgs e) s = " insert into LoginAndOutDate(user_name, Logout_Date) "; s = s + " values(@user_name, CURRENT_TIMESTAMP) "; if (con.State == ConnectionState.Closed) con.Open(); sCommand = new SqlCommand(s, con); sCommand.Parameters.AddWithValue("@user_name", textBox_ForName.Text); sCommand.ExecuteNonQuery(); if (con.State == ConnectionState.Open) con.Close(); this.Close(); this.RefToFormLogin.Show(); }What I have tried:i want when i close form from close button , the value insert..推荐答案这是因为你在this.Close();中调用了FRM_Main_FormClosing,它再次触发了FRM_Main_FormClosing ......哪些调用this.Close()再次,.... 结论:删除 this.Close()在你的FRM_Main_FormClosing事件处理程序。 which Triggers FRM_Main_FormClosing again ... which calls this.Close() again, ....Conclution: Remove this.Close() in your FRM_Main_FormClosing Event handler. 这篇关于system.data.dll中发生了'system.stackoverflowexception'类型的未处理异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-22 20:11