From 522eff61383e9a8acfdf34289cd64a8fdc27bb19 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 30 Apr 2012 15:54:35 +0100 Subject: Consistently use using() to make sure we dispose of used MySqlCommands where this is not already being done. --- OpenSim/Data/MySQL/MySQLUserAccountData.cs | 33 +++++++++++++++--------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'OpenSim/Data/MySQL/MySQLUserAccountData.cs') diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs index aa69d68..e964295 100644 --- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs +++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs @@ -62,23 +62,24 @@ namespace OpenSim.Data.MySQL if (words.Length > 2) return new UserAccountData[0]; - MySqlCommand cmd = new MySqlCommand(); - - if (words.Length == 1) - { - cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?search or LastName like ?search)", m_Realm); - cmd.Parameters.AddWithValue("?search", "%" + words[0] + "%"); - cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); - } - else + using (MySqlCommand cmd = new MySqlCommand()) { - cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?searchFirst or LastName like ?searchLast)", m_Realm); - cmd.Parameters.AddWithValue("?searchFirst", "%" + words[0] + "%"); - cmd.Parameters.AddWithValue("?searchLast", "%" + words[1] + "%"); - cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); - } + if (words.Length == 1) + { + cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?search or LastName like ?search)", m_Realm); + cmd.Parameters.AddWithValue("?search", "%" + words[0] + "%"); + cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); + } + else + { + cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?searchFirst or LastName like ?searchLast)", m_Realm); + cmd.Parameters.AddWithValue("?searchFirst", "%" + words[0] + "%"); + cmd.Parameters.AddWithValue("?searchLast", "%" + words[1] + "%"); + cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); + } - return DoQuery(cmd); + return DoQuery(cmd); + } } } -} +} \ No newline at end of file -- cgit v1.1