All pastes #912815 Raw Edit

Latheesan

public text v1 · immutable
·published 2008-02-21 17:32 UTC
rendered paste body
        public string[] getAccounts()
        {
            int totalAccounts = 0;
            string Query = "SELECT COUNT(`login`) FROM `accounts`";
            MySqlCommand playerCount = new MySqlCommand(Query, this.sqlConn);
            try
            {
                playerCount.ExecuteNonQuery();
                MySqlDataReader myReader = playerCount.ExecuteReader();
                while (myReader.Read() != false)
                {
                    totalAccounts = myReader.GetInt32(0);
                }

                if (totalAccounts == 0)
                {
                    string[] noResult = new string[] { "No Accounts Found" };
                    return noResult;
                }
                
                string[] results = new string[myReader.FieldCount];
                while (myReader.Read())
                {
                    for (int i = 0; i < myReader.FieldCount; i++)
                    {
                        results[i] = myReader.GetValue(i).ToString();
                    }
                }
                myReader.Close();
                return results;
            }
            catch (Exception excp)
            {
                MessageBox.Show(excp.Message, "Could Not Get List Of Accounts", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }