Advertisement
N-am

Untitled

Jan 14th, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 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 MySQL
  13. {
  14. public partial class Form1 : Form
  15. {
  16.  
  17. public Form1()
  18. {
  19. InitializeComponent();
  20. }
  21.  
  22.  
  23.  
  24.  
  25. private void button1_Click(object sender, EventArgs e)
  26. {
  27. MySqlConnection connect = new MySqlConnection("Server=mysql.hostinger.ro;Database=u119248796_mach;Uid=u119248796_mach;Pwd=vezisanu123;");
  28. int i;
  29.  
  30. i = 0;
  31. connect.Open();
  32. MySqlCommand cmd = connect.CreateCommand();
  33. cmd.CommandType = CommandType.Text;
  34. cmd.CommandText = "SELECT * FROM `users` WHERE username='" + textBox1.Text + "' and password='" + textBox2.Text + "'";
  35. cmd.ExecuteNonQuery();
  36. DataTable dt = new DataTable();
  37. MySqlDataAdapter da = new MySqlDataAdapter(cmd);
  38. da.Fill(dt);
  39. i = Convert.ToInt32(dt.Rows.Count.ToString());
  40. if (i == 0)
  41. {
  42. MessageBox.Show("gresit");
  43. }
  44. else
  45. {
  46. MessageBox.Show("corect");
  47. }
  48. }
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement