The Common.ReturnSingleIntegerValue is this:
Code: Select all
public static int ReturnSingleIntegerValue(string _sqlStr)
{
string conString = System.Configuration.ConfigurationManager.AppSettings["DP2"];
SqlConnection con = new SqlConnection(conString);
con.Open();
SqlCommand cmd = new SqlCommand(_sqlStr, con);
cmd.CommandTimeout = 150;
tmpInt = (int)cmd.ExecuteScalar();
con.Close();
con.Dispose();
cmd.Dispose();
return (tmpInt);
}
After closing the form and taking a snapshot, I am told there is an undisposed instance (remove external reference) of a sqldatareader.
Here is a copy of the callstack:
System.Data!System.Data.SqlClient.SqlCommand.RunExecuteReaderTds( CommandBehavior,RunBehavior,bool,bool )
System.Data!System.Data.SqlClient.SqlCommand.RunExecuteReader( CommandBehavior,RunBehavior,bool,string,DbAsyncResult )
System.Data!System.Data.SqlClient.SqlCommand.RunExecuteReader( CommandBehavior,RunBehavior,bool,string )
System.Data!System.Data.SqlClient.SqlCommand.ExecuteScalar()
HRIChimp.Win.Common!HRIChimp.Win.Common.ReturnSingleIntegerValue( string ) Common.cs
HRIChimp.Win.SubjectInfo!HRIChimp.Win.SubjectInfo.SubjectInfo.PopulateDetails() SubjectInfo.cs
HRIChimp.Win.SubjectInfo!HRIChimp.Win.SubjectInfo.SubjectInfo.SubjectInfo_Load( object,EventArgs ) SubjectInfo.cs
System.Windows.Forms!System.Windows.Forms.Form.OnLoad( EventArgs )
HRIChimp.Win.Common!HRIChimp.Win.BaseForm.OnLoad( EventArgs ) BaseForm.cs
System.Windows.Forms!System.Windows.Forms.Form.OnCreateControl()
System.Windows.Forms!System.Windows.Forms.Control.CreateControl( bool )
System.Windows.Forms!System.Windows.Forms.Control.CreateControl()
System.Windows.Forms!System.Windows.Forms.Control.WmShowWindow( ref Message )
System.Windows.Forms!System.Windows.Forms.Control.WndProc( ref Message )
System.Windows.Forms!System.Windows.Forms.ScrollableControl.WndProc( ref Message )
System.Windows.Forms!System.Windows.Forms.ContainerControl.WndProc( ref Message )
System.Windows.Forms!System.Windows.Forms.Form.WmShowWindow( ref Message )
System.Windows.Forms!System.Windows.Forms.Form.WndProc( ref Message )
System.Windows.Forms!System.Windows.Forms.Control.ControlNativeWindow.OnMessage( ref Message )
System.Windows.Forms!System.Windows.Forms.Control.ControlNativeWindow.WndProc( ref Message )
System.Windows.Forms!System.Windows.Forms.NativeWindow.Callback( IntPtr,int,IntPtr,IntPtr )
[Native to managed transition]
[Managed to native transition]
System.Windows.Forms!System.Windows.Forms.UnsafeNativeMethods.IntCreateWindowEx( int,string,string,int,int,int,int,int,HandleRef,HandleRef,HandleRef,object )
System.Windows.Forms!System.Windows.Forms.UnsafeNativeMethods.CreateWindowEx( int,string,string,int,int,int,int,int,HandleRef,HandleRef,HandleRef,object )
[Truncated]
I am not sure if there is an issue with the code or the .NET Framework (2.0)