public PlayerLastSellStoneRecord GetPlayerLastSellStoneRecord(int userID) { MySqlConnection myconn = null; MySqlCommand mycmd = null; try { myconn = MyDBHelper.Instance.CreateConnection(); string sqlText = "select * from playerlastsellstonerecord where `UserID` = @UserID;"; mycmd = myconn.CreateCommand(); mycmd.CommandText = sqlText; mycmd.Parameters.AddWithValue("@UserID", userID); myconn.Open(); MySqlDataAdapter adapter = new MySqlDataAdapter(mycmd); DataTable table = new DataTable(); adapter.Fill(table); var records = MetaDBAdapter <PlayerLastSellStoneRecord> .GetPlayerLastSellStoneRecord(table); table.Clear(); table.Dispose(); adapter.Dispose(); if (records.Length == 0) { return(null); } return(records[0]); } finally { if (mycmd != null) { mycmd.Dispose(); } MyDBHelper.Instance.DisposeConnection(myconn); } }