android - Closing SQLite with C# in Unity -


i'm making app android unity now.

but have very basic questions sqlite because i've never used database yet.

dbcmd.commandtext = "some select command here";  idatareader reader = dbcmd.executereader();  // jobs reader..   dbcmd.commandtext = "another select command here";  reader = dbcmd.executereader();  // jobs reader..   reader.close(); dbcmd.dispose(); dbconn.close();  reader = null; dbcmd = null; dbconn = null; 

i need call executereader() method several times that.

here questions.

  1. do have close reader before call executereader() method again?

  2. do have assign null variables after closing reader , database above?

thanks in advance!

  1. read using statement - construct designed specially such use cases.
  2. yes, second call executereader() returns brand new reader object, must closed/disposed too, when don't need anymore. it's question variables , object references store.
  3. it practice in many cases (especially if reader , dbcmd instance fields), because mark no reference valid (non-disposed) object in variable. not critical, if variable is, example, local current function.

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

php - How do you embed a video into a custom theme on WordPress? -