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.
do have close reader before call executereader() method again?
do have assign null variables after closing reader , database above?
thanks in advance!
- read using statement - construct designed specially such use cases.
- 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.
- 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
Post a Comment