F
Frank
Hello,
I have a piece of code in which some reference to the SQLadapter object
still exists after calling it, how can I get rid of it?
I tried disposing the object, closing it, no difference. It leaves just a
small object, but this application is supposed to run for months and then a
lot of small objects add up to dozens of Mb's.
Does anyone have an idea?
Thanks
Frank
The method is available in a class that is created once.
SqlConnection _SqlConnection= new
SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
SqlCommand _SqlCommand = new SqlCommand(StoredProcedure,_SqlConnection);
_SqlCommand.CommandType=CommandType.StoredProcedure;
SqlDataAdapter _SqlDataAdapter = new SqlDataAdapter(_SqlCommand);
DataSet _DataSet= new DataSet();
foreach (string name in Parameters.Keys)
{_SqlDataAdapter.SelectCommand.Parameters.Add("@" + name,
Parameters[name]);}
try{_SqlDataAdapter.Fill(_DataSet,StoredProcedure);}
catch (SqlException
e){{Console.WriteLine(StoredProcedure+e.Message+e.StackTrace);}}
finally{_SqlConnection.Close();}
I have a piece of code in which some reference to the SQLadapter object
still exists after calling it, how can I get rid of it?
I tried disposing the object, closing it, no difference. It leaves just a
small object, but this application is supposed to run for months and then a
lot of small objects add up to dozens of Mb's.
Does anyone have an idea?
Thanks
Frank
The method is available in a class that is created once.
SqlConnection _SqlConnection= new
SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
SqlCommand _SqlCommand = new SqlCommand(StoredProcedure,_SqlConnection);
_SqlCommand.CommandType=CommandType.StoredProcedure;
SqlDataAdapter _SqlDataAdapter = new SqlDataAdapter(_SqlCommand);
DataSet _DataSet= new DataSet();
foreach (string name in Parameters.Keys)
{_SqlDataAdapter.SelectCommand.Parameters.Add("@" + name,
Parameters[name]);}
try{_SqlDataAdapter.Fill(_DataSet,StoredProcedure);}
catch (SqlException
e){{Console.WriteLine(StoredProcedure+e.Message+e.StackTrace);}}
finally{_SqlConnection.Close();}