Пример #1
0
        public RouletteRoundInfo GetLastRouletteRoundInfo()
        {
            MySqlConnection myconn = null;
            MySqlCommand    mycmd  = null;

            try
            {
                myconn = MyDBHelper.Instance.CreateConnection();
                myconn.Open();
                string sqlText = "select * from rouletteroundinfo order by id desc limit 1 ;";
                mycmd             = myconn.CreateCommand();
                mycmd.CommandText = sqlText;
                MySqlDataAdapter adapter = new MySqlDataAdapter(mycmd);

                DataTable table = new DataTable();
                adapter.Fill(table);
                var items = MetaDBAdapter <RouletteRoundInfo> .GetRouletteRoundInfoFromDataTable(table);

                table.Clear();
                table.Dispose();
                adapter.Dispose();
                if (items == null || items.Length == 0)
                {
                    return(null);
                }

                return(items[0]);
            }
            finally
            {
                if (mycmd != null)
                {
                    mycmd.Dispose();
                }
                if (myconn != null)
                {
                    myconn.Close();
                    myconn.Dispose();
                }
            }
        }
Пример #2
0
        public RouletteRoundInfo[] GetAllRouletteRoundInfo()
        {
            MySqlConnection myconn = null;
            MySqlCommand    mycmd  = null;

            try
            {
                myconn = MyDBHelper.Instance.CreateConnection();
                myconn.Open();
                string sqlText = "select * from rouletteroundinfo ;";
                mycmd             = myconn.CreateCommand();
                mycmd.CommandText = sqlText;
                MySqlDataAdapter adapter = new MySqlDataAdapter(mycmd);

                DataTable table = new DataTable();
                adapter.Fill(table);
                var items = MetaDBAdapter <RouletteRoundInfo> .GetRouletteRoundInfoFromDataTable(table);

                table.Clear();
                table.Dispose();
                adapter.Dispose();
                return(items);
            }
            finally
            {
                if (mycmd != null)
                {
                    mycmd.Dispose();
                }
                if (myconn != null)
                {
                    myconn.Close();
                    myconn.Dispose();
                }
            }
        }