aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Data.SQLite/SQLiteUserData.cs')
-rw-r--r--OpenSim/Framework/Data.SQLite/SQLiteUserData.cs41
1 files changed, 23 insertions, 18 deletions
diff --git a/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs b/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs
index 7647d02..ed8275e 100644
--- a/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs
+++ b/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs
@@ -51,6 +51,9 @@ namespace OpenSim.Framework.Data.SQLite
51 51
52 private const string userSelect = "select * from users"; 52 private const string userSelect = "select * from users";
53 private const string userFriendsSelect = "select a.ownerID as ownerID,a.friendID as friendID,a.friendPerms as friendPerms,b.friendPerms as ownerperms, b.ownerID as fownerID, b.friendID as ffriendID from userfriends as a, userfriends as b"; 53 private const string userFriendsSelect = "select a.ownerID as ownerID,a.friendID as friendID,a.friendPerms as friendPerms,b.friendPerms as ownerperms, b.ownerID as fownerID, b.friendID as ffriendID from userfriends as a, userfriends as b";
54
55 private const string AvatarPickerAndSQL = "select * from users where username like :username and surname like :surname";
56 private const string AvatarPickerOrSQL = "select * from users where username like :username or surname like :surname";
54 57
55 private DataSet ds; 58 private DataSet ds;
56 private SqliteDataAdapter da; 59 private SqliteDataAdapter da;
@@ -243,41 +246,43 @@ namespace OpenSim.Framework.Data.SQLite
243 querysplit = query.Split(' '); 246 querysplit = query.Split(' ');
244 if (querysplit.Length == 2) 247 if (querysplit.Length == 2)
245 { 248 {
246 string select = "username like '" + querysplit[0] + "%' and surname like '" + querysplit[1] + "%'"; 249 using (SqliteCommand cmd = new SqliteCommand(AvatarPickerAndSQL, g_conn))
247 lock (ds)
248 { 250 {
249 DataRow[] rows = ds.Tables["users"].Select(select); 251 cmd.Parameters.Add(new SqliteParameter(":username", querysplit[0] + "%"));
250 if (rows.Length > 0) 252 cmd.Parameters.Add(new SqliteParameter(":surname", querysplit[1] + "%"));
253
254 using (IDataReader reader = cmd.ExecuteReader())
251 { 255 {
252 for (int i = 0; i < rows.Length; i++) 256 while (reader.Read())
253 { 257 {
254 Framework.AvatarPickerAvatar user = new Framework.AvatarPickerAvatar(); 258 Framework.AvatarPickerAvatar user = new Framework.AvatarPickerAvatar();
255 DataRow row = rows[i]; 259 user.AvatarID = new LLUUID((string) reader["UUID"]);
256 user.AvatarID = new LLUUID((string) row["UUID"]); 260 user.firstName = (string) reader["username"];
257 user.firstName = (string) row["username"]; 261 user.lastName = (string) reader["surname"];
258 user.lastName = (string) row["surname"];
259 returnlist.Add(user); 262 returnlist.Add(user);
260 } 263 }
264 reader.Close();
261 } 265 }
262 } 266 }
263 } 267 }
264 else if (querysplit.Length == 1) 268 else if (querysplit.Length == 1)
265 { 269 {
266 string select = "username like '" + querysplit[0] + "%' OR surname like '" + querysplit[0] + "%'"; 270 using (SqliteCommand cmd = new SqliteCommand(AvatarPickerOrSQL, g_conn))
267 lock (ds)
268 { 271 {
269 DataRow[] rows = ds.Tables["users"].Select(select); 272 cmd.Parameters.Add(new SqliteParameter(":username", querysplit[0] + "%"));
270 if (rows.Length > 0) 273 cmd.Parameters.Add(new SqliteParameter(":surname", querysplit[0] + "%"));
274
275 using (IDataReader reader = cmd.ExecuteReader())
271 { 276 {
272 for (int i = 0; i < rows.Length; i++) 277 while (reader.Read())
273 { 278 {
274 Framework.AvatarPickerAvatar user = new Framework.AvatarPickerAvatar(); 279 Framework.AvatarPickerAvatar user = new Framework.AvatarPickerAvatar();
275 DataRow row = rows[i]; 280 user.AvatarID = new LLUUID((string) reader["UUID"]);
276 user.AvatarID = new LLUUID((string) row[0]); 281 user.firstName = (string) reader["username"];
277 user.firstName = (string) row[1]; 282 user.lastName = (string) reader["surname"];
278 user.lastName = (string) row[2];
279 returnlist.Add(user); 283 returnlist.Add(user);
280 } 284 }
285 reader.Close();
281 } 286 }
282 } 287 }
283 } 288 }