DataTable Dispose??

grip003

Well-known member
Joined
Sep 2, 2004
Messages
89
Location
North Carolina
I am having a major memory problem. I am loading a DataTable from a MySQL database, but when I dispose the DataTable, no memory is freed. I need to open about 70 tables and dump all the records into another database, but I keep getting an out of memory problem. Can anyone tell me how to completely empty a DataTable from memory? Here is the function I use to load my table:

Code:
public DataTable SelectSQL_DT(string selectStr, string dtName)
{
	try
	{
		MySqlConnection dbConnection = 
			new MySqlConnection(connectionString);
		dbConnection.Open();

		MySqlDataAdapter adapter = 
			new MySqlDataAdapter(selectStr, dbConnection);

		DataTable my_table = new DataTable(dtName);
		adapter.Fill(my_table);

		// Dispose of the adapter, it is no longer needed
		adapter.Dispose();

		dbConnection.Close();
		dbConnection.Dispose();
		return my_table;

	}
	catch (MySqlException e)
	{
		throw new Exception("SQL statement execution " +
			"error!!\n\n" + "Trying statement:\n  " + selectStr +
			"\n\n" + e.Message);
	}

} //end SelectSQL_DS(string selectStr, string dsName)
 
Back
Top