This commit is contained in:
UnknownShadow200 2018-07-19 05:02:33 +10:00
parent 85ee4615a8
commit eed5f241b4

View File

@ -358,7 +358,6 @@ namespace System.Data.SQLite {
public sealed class SQLiteCommand : IDbCommand { public sealed class SQLiteCommand : IDbCommand {
string strCmdText, strRemaining; string strCmdText, strRemaining;
SQLiteConnection conn; SQLiteConnection conn;
SQLiteParameterCollection parameters = new SQLiteParameterCollection(); SQLiteParameterCollection parameters = new SQLiteParameterCollection();
SQLiteStatement stmt; SQLiteStatement stmt;
@ -369,25 +368,27 @@ namespace System.Data.SQLite {
if (connection != null) Connection = connection; if (connection != null) Connection = connection;
} }
void DisposeStatement() {
if (stmt != null) stmt.Dispose();
stmt = null;
}
public void Dispose() { public void Dispose() {
conn = null; conn = null;
parameters.Clear(); parameters.Clear();
strCmdText = null; strCmdText = null;
strRemaining = null; strRemaining = null;
DisposeStatement();
if (stmt != null) stmt.Dispose();
stmt = null;
} }
internal SQLiteStatement NextStatement() { internal SQLiteStatement NextStatement() {
if (stmt != null) stmt.Dispose(); if (stmt != null) DisposeStatement();
if (String.IsNullOrEmpty(strRemaining)) return null; if (String.IsNullOrEmpty(strRemaining)) return null;
stmt = null;
try { try {
stmt = conn.Prepare(strRemaining, ref strRemaining); stmt = conn.Prepare(strRemaining, ref strRemaining);
} catch (Exception) { } catch (Exception) {
if (stmt != null) { stmt.Dispose(); stmt = null; } DisposeStatement();
// Cannot continue on, so set the remaining text to null. // Cannot continue on, so set the remaining text to null.
strRemaining = null; strRemaining = null;
throw; throw;