public GambleStonePlayerBetRecord[] GetMonthGambleStonePlayerBetRecord(int userID, int year, int month, MyDateTime beginTime) { GambleStonePlayerBetRecord[] records = null; MyDBHelper.Instance.ConnectionCommandSelect(mycmd => { string tableName = GambleStonePlayerBetRecordTableNamePrefix + year.ToString("0000") + month.ToString("00"); string sqlSelectTableName = "show tables where Tables_in_" + MyDBHelper.DataBaseServerName + " = '" + tableName + "'"; mycmd.CommandText = sqlSelectTableName; DataTable table = new DataTable(); MySqlDataAdapter adapter = new MySqlDataAdapter(mycmd); adapter.Fill(table); adapter.Dispose(); if (table.Rows.Count == 0) { return; } string sqlText = "select * from " + tableName + " where UserID = @UserID"; if (beginTime != null && beginTime.Year == year && beginTime.Month == month) { sqlText += " and Time >= @BeginTime "; mycmd.Parameters.AddWithValue("@BeginTime", beginTime); } sqlText += " order by Time desc"; mycmd.CommandText = sqlText; mycmd.Parameters.AddWithValue("@UserID", userID); table.Clear(); adapter = new MySqlDataAdapter(mycmd); adapter.Fill(table); records = MetaDBAdapter <GambleStonePlayerBetRecord> .GetGambleStonePlayerBetRecordFromDataTable(table); table.Clear(); table.Dispose(); adapter.Dispose(); }); return(records); }