Gladimir Posted April 23, 2003 Posted April 23, 2003 (edited) I'm attempting to allow the .NET Garbage Collector to handle as much as possible automatically, but I know there are unhandled objects like filestreams and database connections. If the following function is called from the Form_load event, would I need to do any garbage collection? public string getlastMasterID() { // create dataset in memory DataSet ds1 = new DataSet(); ds1.Tables.Add("idTable"); // initialize the master data connection object dbMaster masterdb = new dbMaster(); OleDbConnection master = masterdb.m_master; // create and initialize data adapter object string stridSelect = "SELECT * FROM idTable"; OleDbDataAdapter idAdapter = new OleDbDataAdapter(stridSelect, master); // fill the table in memory from the database table idAdapter.Fill(ds1, "idTable"); // determine the last master id number and the last temp asset id DataRowCollection drc = ds1.Tables[0].Rows; string strlastMasterID = drc[0][1].ToString(); return strlastMasterID; } Edited April 23, 2003 by Gladimir Quote Never ascribe to malice that which is adequately explained by incompetence. - Napoleon Bonaparte
*Gurus* Derek Stone Posted April 23, 2003 *Gurus* Posted April 23, 2003 would I need to do any garbage collection? No, but you'll want to call the Close method of your OleDbConnection. Quote Posting Guidelines
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.