mirror of
https://github.com/opensim/opensim.git
synced 2026-08-04 08:06:27 +08:00
workaround potencial memory leaks
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user