From 94da908813e42c328572bc5da2ddc41b6664b59c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 14 Nov 2012 04:45:59 +0000 Subject: More consistently dispose of SqliteCommand in OpenSim.Data.SQLite where possible. Not doing SQLiteInventoryStore since this is no longer used and should disappear in the future. --- OpenSim/Data/SQLite/SQLiteFriendsData.cs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'OpenSim/Data/SQLite/SQLiteFriendsData.cs') diff --git a/OpenSim/Data/SQLite/SQLiteFriendsData.cs b/OpenSim/Data/SQLite/SQLiteFriendsData.cs index 5f68977..cab85eb 100644 --- a/OpenSim/Data/SQLite/SQLiteFriendsData.cs +++ b/OpenSim/Data/SQLite/SQLiteFriendsData.cs @@ -53,13 +53,13 @@ namespace OpenSim.Data.SQLite public FriendsData[] GetFriends(string userID) { - SqliteCommand cmd = new SqliteCommand(); - - cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = :PrincipalID", m_Realm); - cmd.Parameters.AddWithValue(":PrincipalID", userID.ToString()); - - return DoQuery(cmd); + using (SqliteCommand cmd = new SqliteCommand()) + { + cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = :PrincipalID", m_Realm); + cmd.Parameters.AddWithValue(":PrincipalID", userID.ToString()); + return DoQuery(cmd); + } } public bool Delete(UUID principalID, string friend) @@ -69,13 +69,14 @@ namespace OpenSim.Data.SQLite public bool Delete(string principalID, string friend) { - SqliteCommand cmd = new SqliteCommand(); - - cmd.CommandText = String.Format("delete from {0} where PrincipalID = :PrincipalID and Friend = :Friend", m_Realm); - cmd.Parameters.AddWithValue(":PrincipalID", principalID.ToString()); - cmd.Parameters.AddWithValue(":Friend", friend); + using (SqliteCommand cmd = new SqliteCommand()) + { + cmd.CommandText = String.Format("delete from {0} where PrincipalID = :PrincipalID and Friend = :Friend", m_Realm); + cmd.Parameters.AddWithValue(":PrincipalID", principalID.ToString()); + cmd.Parameters.AddWithValue(":Friend", friend); - ExecuteNonQuery(cmd, m_Connection); + ExecuteNonQuery(cmd, m_Connection); + } return true; } -- cgit v1.1