Advertisement
Guest User

Untitled

a guest
Jul 9th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. class MSQL
  2. {
  3. public string login;
  4. public string password;
  5. private string aut;
  6. public void conection()
  7. {
  8. string CommandText = "select name from new_table where name='" + login +"AND password='"+ password + "'";
  9. string Connect = "Database=new_schema;Data Source=localhost;User Id=root;Password=root";
  10. MySqlConnection myConnect = new MySqlConnection(Connect);
  11. myConnect.Open();
  12. MySqlCommand myCommnd = new MySqlCommand(CommandText, myConnect);
  13. string aut = myCommnd.ExecuteScalar().ToString();
  14. myConnect.Close();
  15. if (aut != "")
  16. {
  17. MessageBox.Show("ok");
  18. }
  19. else
  20. {
  21. MessageBox.Show("error");
  22. }
  23. }
  24.  
  25. }
  26.  
  27. class MSQL
  28. {
  29. public string login;
  30. public string password;
  31. private string aut;
  32. public void conection()
  33. {
  34. string CommandText = "SELECT name FROM new_table WHERE name='" + login +"'AND password='"+ password + "'";
  35. string Connect = "server=localhost;username=root;database=new_schema;password=root";
  36. MySqlConnection myConnect = new MySqlConnection(Connect);
  37. myConnect.Open();
  38. MySqlCommand myCommnd = new MySqlCommand(CommandText, myConnect);
  39. try
  40. {
  41. string aut = myCommnd.ExecuteScalar().ToString();
  42. MessageBow.Show(aut);
  43. myConnect.Close();
  44. }
  45. catch (Exception ex)
  46. {
  47. MessageBox.Show("Ошибка у нас такая: " + ex.Message);
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement