Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Data.SqlClient;
- namespace WindowsFormsApplication1
- {
- public partial class LOGIN : Form
- {
- public LOGIN()
- {
- InitializeComponent();
- }
- private void button2_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)v11.0;AttachDbFilename=C:UserskenluiDocumentsLoginDate.mdf;Integrated Security=True;Connect Timeout=30;");
- SqlDataAdapter sda = new SqlDataAdapter("Select Count(*) from Login where Username ='" + textBox1.Text + "' and Password = '" + textBox2.Text + "'", con);
- DataTable dt = new DataTable();
- sda.Fill(dt);
- if (dt.Rows[0][0].ToString() == "1")
- {
- this.Hide();
- main ss = new main();
- ss.Show();
- }
- else
- {
- MessageBox.Show("Please Check Username and Password");
- }
- }
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- using (SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)v11.0;AttachDbFilename=C:UserskenluiDocumentsLoginDate.mdf;Integrated Security=True;Connect Timeout=30;"))
- using (SqlDataAdapter sda = new SqlDataAdapter("Select Count(*) from Login where Username = @userName and Password = @password", con))
- using (DataTable dt = new DataTable())
- {
- sda.SelectCommand.Parameters.Add(new SqlParameter("@userName", SqlDbType.VarChar) { Value = textBox1.Text });
- // this should be a hash of the password, not the plain text value
- sda.SelectCommand.Parameters.Add(new SqlParameter("@password", SqlDbType.VarChar) { Value = textBox2.Text });
- sda.Fill(dt);
- if (dt.Rows[0][0].ToString() == "1")
- {
- this.Hide();
- main ss = new main();
- ss.Show();
- }
- else
- {
- MessageBox.Show("Please Check Username and Password");
- }
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- using (SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)v11.0;AttachDbFilename=C:UserskenluiDocumentsLoginDate.mdf;Integrated Security=True;Connect Timeout=30;"))
- using (SqlCommand sda = new SqlCommand("Select 1 from Login where Username = @userName and Password = @password", con))
- {
- sda.Parameters.Add(new SqlParameter("@userName", SqlDbType.VarChar) { Value = textBox1.Text });
- // this should be a hash of the password, not the plain text value
- sda.Parameters.Add(new SqlParameter("@password", SqlDbType.VarChar) { Value = textBox2.Text });
- var result = sda.ExecuteScalar();
- if (result != null && 1 == (int)result)
- {
- this.Hide();
- main ss = new main();
- ss.Show();
- }
- else
- {
- MessageBox.Show("Please Check Username and Password");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement