Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. private static string[] get_word()
  2. {
  3. string[] temp = new string[2];
  4. using (MySqlConnection connection = new MySqlConnection("Database=proj;Data Source=kfreebie.ru; User Id=anagrammist;SslMode=none;Password=YRxDz6aUSTWEiFeo"))
  5. {
  6. connection.Open();
  7. using (MySqlCommand command = connection.CreateCommand())
  8. {
  9. command.CommandText = "select wtext from (select wtext from words order by rand() limit 1) kek";
  10. using (MySqlDataReader reader = command.ExecuteReader())
  11. {
  12. try
  13. {
  14. reader.Read();
  15. temp[0] = reader.GetString(0);//0-норм, 1 - мешать
  16. temp[1] = reader.GetString(0);
  17. }
  18. catch
  19. {
  20. return temp;
  21. }
  22. }
  23. command.CommandText = string.Format("delete from words where wtext='{0}'", temp[0]);
  24. command.ExecuteNonQuery();
  25. }
  26.  
  27. connection.Close();
  28. Random rand = new Random();
  29. temp[1] = String.Join("", temp[1].OrderBy(x => x).ToArray());
  30. char[] tempchars = temp[1].ToCharArray();
  31. tempchars[rand.Next(0, temp[1].Length / 2)] = '*'; tempchars[rand.Next(temp[1].Length / 2, temp[1].Length)] = '*';
  32. temp[1] = new string(tempchars);
  33. return temp;
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement