Advertisement
Guest User

Untitled

a guest
Apr 26th, 2015
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. static public DataSet getUserShopItemDS(string username,List<shopItem> items)
  2. {
  3. string madeForCommand = "SELECT ItemName as Name,ItemPicture as Picture,ItemHeroModif as Assistance,ItemTroopModif as Charisma, HerbCost as Herbs, GemCost as Gems FROM Item WHERE ItemID = ";
  4. int count = 0;
  5. foreach (shopItem item in items)
  6. {
  7. madeForCommand += "@value"+count+" OR ";
  8. count++;
  9. }
  10. madeForCommand = madeForCommand.Substring(0, madeForCommand.Length - 3);
  11. OleDbCommand command = GenerateConnection(madeForCommand);
  12. for (int i = 0; i < madeForCommand.Length; i++)
  13. {
  14. // Checking for each one of the values, and adding the parameters each time.
  15. if (madeForCommand[i] == '@')
  16. {
  17. string substr = "";
  18. int k=0;
  19. for (; madeForCommand[i + k] != ' ' && i + k < madeForCommand.Length; k++) ;
  20. substr = madeForCommand.Substring(i, k); // valueX
  21. string supersubstr = substr.Substring(6); // X
  22. int numOutOfSubstr = int.Parse(supersubstr); // the value number itself, which represends the ID of the item for the user.
  23. command.Parameters.AddWithValue(substr, items[numOutOfSubstr].ID);
  24. }
  25. }
  26. //OleDbCommand command2 = GenerateConnection("SELECT Item FROM ItemPlayerConnection WHERE Player=@Playa AND Inventory=@value");
  27. //command2.Parameters.AddWithValue("@Playa", username);
  28. //command2.Parameters.AddWithValue("@value", false);//Looking for shop items, not inventory.
  29. var FreestyleAdaptor = new OleDbDataAdapter();
  30. FreestyleAdaptor.SelectCommand = command;
  31. DataSet Items = new DataSet();
  32. FreestyleAdaptor.Fill(Items);//The error is thrown here.
  33. return Items;
  34. }
  35.  
  36. int count = 0;
  37. foreach (shopItem item in items)
  38. {
  39. count += 1;
  40. madeForCommand += "@value" + count + " OR ";
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement