Garbage Collection Question...

Gladimir

Regular
Joined
Mar 29, 2003
Messages
60
Location
San Diego, CA
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?

C#:
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;
}
 
Last edited:
Back
Top