workaround potencial memory leaks

This commit is contained in:
UbitUmarov
2016-08-22 06:03:39 +01:00
parent 52a80f1742
commit 5d5bad5fc1
3 changed files with 66 additions and 61 deletions

View File

@@ -316,15 +316,16 @@ namespace OpenSim.Data.MySQL
return 0;
}
MySqlCommand cmd = conn.CreateCommand();
cmd.CommandText = String.Format("select count(*) as count from {0}", m_Table);
using (IDataReader reader = cmd.ExecuteReader())
using(MySqlCommand cmd = conn.CreateCommand())
{
reader.Read();
cmd.CommandText = String.Format("select count(*) as count from {0}",m_Table);
count = Convert.ToInt32(reader["count"]);
using (IDataReader reader = cmd.ExecuteReader())
{
reader.Read();
count = Convert.ToInt32(reader["count"]);
}
}
}
@@ -333,15 +334,15 @@ namespace OpenSim.Data.MySQL
public bool Delete(string id)
{
MySqlCommand cmd = new MySqlCommand();
using(MySqlCommand cmd = new MySqlCommand())
{
cmd.CommandText = String.Format("delete from {0} where id = ?id", m_Table);
cmd.CommandText = String.Format("delete from {0} where id = ?id",m_Table);
cmd.Parameters.AddWithValue("?id", id);
cmd.Parameters.AddWithValue("?id", id);
ExecuteNonQuery(cmd);
cmd.Dispose();
ExecuteNonQuery(cmd);
}
return true;
}