Advertisement
Guest User

Untitled

a guest
May 25th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 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 WindowsFormsApplication3
  13. {
  14. public partial class Form1 : Form
  15. {
  16. public Form1()
  17. {
  18. InitializeComponent();
  19. }
  20.  
  21. private void label1_Click(object sender, EventArgs e)
  22. {
  23.  
  24. }
  25.  
  26. private void button1_Click(object sender, EventArgs e)
  27. {
  28. try
  29.  
  30. {
  31. string myConnection = "datasource=s59.hekko.pl;port=3306;username=truex2_kuba;password=xxxx";
  32. SqlConnection myConn = new MySqlConnection(myConnection);
  33. MySqlCommand SelectCommand = new MySqlCommand("select * from databaase.users where uid='" + this.uid.Text + "' and pwd='" + this.pwd.Text + "' ;", myConn);
  34. MySqlDataReader myReader;
  35. myConnection.Open();
  36. myReader = SelectCommand.ExecuteReader();
  37. int count = 0;
  38. while (myReader())
  39. {
  40. count = count + 1;
  41. }
  42. if (count == 1)
  43. {
  44. MessageBox.Show("Nazwa uzytkownika i haslo sa poprawne");
  45.  
  46.  
  47. }
  48. else if (count > 1)
  49. {
  50. MessageBox.Show("Wpisano zle dane uzytkownika");
  51.  
  52. }
  53. else
  54. MessageBox.Show("Wpisano zle dane uzytkownika");
  55. MyConn.Close();
  56. }
  57. catch (Exception ex)
  58. {
  59. MessageBox.Show(ex.Message);
  60.  
  61. }
  62. }
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement