public static void LoadItems() { lock (DatabaseHandler.ConnectionLocker) { var sqlText = "SELECT * FROM datas_items"; var sqlCommand = new MySqlCommand(sqlText, DatabaseHandler.Connection); var sqlReader = sqlCommand.ExecuteReader(); while (sqlReader.Read()) { var item = new Models.Items.ItemModel(); item.ID = sqlReader.GetInt32("ID"); item.Pods = sqlReader.GetInt16("Weight"); item.Price = sqlReader.GetInt32("Price"); item.Type = sqlReader.GetInt16("Type"); item.Level = sqlReader.GetInt16("Level"); item.Jet = sqlReader.GetString("Stats"); item.Condistr = sqlReader.GetString("Conditions"); item.ParseWeaponInfos(sqlReader.GetString("WeaponInfo")); item.ParseRandomJet(); lock(ItemsList) ItemsList.Add(item); } sqlReader.Close(); } Utilities.Loggers.StatusLogger.Write(string.Format("Loaded @'{0}' items@ from the database !", ItemsList.Count)); }
public static void LoadItems() { var sqlText = "SELECT * FROM items"; var sqlCommand = new MySqlCommand(sqlText, Program.DBHelper.Use()); var sqlReader = sqlCommand.ExecuteReader(); while (sqlReader.Read()) { var item = new Models.Items.ItemModel() { ID = sqlReader.GetInt32("ID"), Pods = sqlReader.GetInt16("Weight"), Price = sqlReader.GetInt32("Price"), Type = sqlReader.GetInt16("Type"), Level = sqlReader.GetInt16("Level"), Jet = sqlReader.GetString("Stats"), Condistr = sqlReader.GetString("Conditions"), }; item.ParseWeaponInfos(sqlReader.GetString("WeaponInfo")); item.ParseRandomJet(); ItemsList.Add(item); } sqlReader.Close(); Utilities.Loggers.Status.Write(string.Format("Loaded '{0}' items from the database !", ItemsList.Count)); }