Guest User

Untitled

a guest
May 4th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 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 System.Data.SqlClient;
  11.  
  12. namespace Login
  13. {
  14. public partial class Form1 : Form
  15. {
  16. public Form1()
  17. {
  18. InitializeComponent();
  19. }
  20.  
  21. private void btnExit_Click(object sender, EventArgs e)
  22. {
  23. this.Close();
  24. }
  25.  
  26. private void btnLogin_Click(object sender, EventArgs e)
  27. {
  28.  
  29. SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=H:\My things\Cursuri IT\Curs C# Romana\Exercitii c#\Login\Data.mdf;Integrated Security=True;Connect Timeout=30");
  30. SqlDataAdapter sda = new SqlDataAdapter("SELECT COUNT(*) FROM LOGIN WHERE USERNAME = '" + txtUsername.Text + "' AND PASSWORD = '" + txtPassword.Text + "'", con);
  31. DataTable dt = new DataTable();
  32. sda.Fill(dt);
  33.  
  34. if (dt.Rows[0][0].ToString() == "1")
  35. {
  36. this.Hide();
  37. Main ss = new Main();
  38. ss.Show();
  39. }
  40. else
  41. {
  42. MessageBox.Show("Please check your username and password");
  43. }
  44.  
  45.  
  46. }
  47. }
  48. }
Add Comment
Please, Sign In to add comment