Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (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 by Gladimir
Never ascribe to malice that which is adequately explained by incompetence. - Napoleon Bonaparte

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...