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