public AgentUserInfo[] GetAllAgentUsers() { MySqlConnection myconn = null; MySqlCommand mycmd = null; try { myconn = MyDBHelper.Instance.CreateConnection(); string sqlTextA = "select * from agentuserinfo; "; mycmd = myconn.CreateCommand(); mycmd.CommandText = sqlTextA; myconn.Open(); MySqlDataAdapter adapter = new MySqlDataAdapter(mycmd); DataTable tableAgents = new DataTable(); adapter.Fill(tableAgents); if (tableAgents.Rows.Count == 0) { return(null); } DataTable tablePlayers = new DataTable(); string sqlTextB = "select a.*, c.UserName as ReferrerUserName, b.* , g.Gravel, g.FirstGetGravelTime from playersimpleinfo a left join playersimpleinfo c on a.ReferrerUserID = c.id left join playerfortuneinfo b on a.id = b.userId left join playergravelinfo g on a.id = g.UserID where a.GroupType = @GroupType"; mycmd = new MySqlCommand(sqlTextB, myconn); mycmd.Parameters.AddWithValue("@GroupType", (int)PlayerGroupType.AgentPlayer); adapter = new MySqlDataAdapter(mycmd); adapter.Fill(tablePlayers); var players = MetaDBAdapter <PlayerInfo> .GetPlayerInfoFromDataTable(tablePlayers); if (players == null) { return(null); } var lists = MetaDBAdapter <AgentUserInfo> .GetAgentUserInfoFromDataTable(tableAgents, players); tablePlayers.Clear(); tablePlayers.Dispose(); adapter.Dispose(); return(lists); } finally { if (mycmd != null) { mycmd.Dispose(); } if (myconn != null) { myconn.Close(); myconn.Dispose(); } } }