Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using MySql.Data.MySqlClient;
  11.  
  12. namespace program1
  13. {
  14. public partial class Form2 : Form
  15. {
  16. public Form2()
  17. {
  18. InitializeComponent();
  19. }
  20. string connectionString = "datasource=remotemysql.com;port=3306;username=Pcmvh65uNG;password=8D2mDip530;database=Pcmvh65uNG;";
  21. string username;
  22. string password;
  23. string query;
  24.  
  25. private void textBox1_TextChanged(object sender, EventArgs e)
  26. {
  27. Convert.ToString(textBox1.Text);
  28. username = textBox1.Text;
  29. }
  30.  
  31. private void textBox2_TextChanged(object sender, EventArgs e)
  32. {
  33. Convert.ToString(textBox2.Text);
  34. password = textBox2.Text;
  35. }
  36.  
  37. private void button1_Click(object sender, EventArgs e)
  38. {
  39. query = "SELECT * FROM `users` WHERE (`username` = '" + username + "' AND `password` = '" + password + "')";
  40. MySqlConnection databaseConnection = new MySqlConnection(connectionString);
  41. MySqlCommand commandDatabase = new MySqlCommand(query, databaseConnection);
  42. try
  43. {
  44. databaseConnection.Open();
  45.  
  46. MySqlDataReader myreader = commandDatabase.ExecuteReader();
  47. if (myreader.HasRows)
  48. {
  49. MessageBox.Show("bun");
  50. }
  51. else
  52. {
  53. MessageBox.Show("rau");
  54. }
  55. }
  56. catch (MySqlException numar)
  57. {
  58. if (numar.Number == 1042)
  59. {
  60. MessageBox.Show("Server is down");
  61. }
  62. }
  63. }
  64.  
  65. private void label1_Click(object sender, EventArgs e)
  66. {
  67. Form1 fm1 = new Form1();
  68. Form2 fm2 = new Form2();
  69. fm1.Show();
  70. fm2.Close();
  71.  
  72. }
  73. }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement