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 Editer12
- {
- public partial class Form2 : Form
- {
- public Form2()
- {
- InitializeComponent();
- }
- string cs = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename= C:\Program Files\Microsoft SQL Server\MSSQL11.SKILLAGEITDB2\MSSQL\DATA\Skillage.mdf;Integrated Security = True; Connect Timeout = 30";
- private void Form2_Load(object sender, EventArgs e)
- {
- }
- private void button1_Click(object sender, EventArgs e)
- {
- if (UserName.Text == "" || Password.Text == "")
- {
- MessageBox.Show("ITS WRONG ALL WRONG");
- return;
- }
- try
- {
- SqlConnection cr = new SqlConnection(cs);
- SqlCommand cmd = new SqlCommand("select * from LoginForm where UserName=@username and Password=@password", cr);
- cmd.Parameters.AddWithValue("@username", UserName.Text);
- cmd.Parameters.AddWithValue("@password", Password.Text); cr.Open();
- SqlDataAdapter adapt = new SqlDataAdapter(cmd);
- DataSet ds = new DataSet();
- adapt.Fill(ds);
- cr.Close();
- int count = ds.Tables[0].Rows.Count;
- if (count == 1)
- {
- if (UserName.Text == "" || Password.Text == "")
- {
- MessageBox.Show("Access GRANTED!!!!!!!!");
- this.Hide();
- Form1 fm = new Form1();
- fm.Show();
- }
- else
- {
- MessageBox.Show("ACCESS DENIED!!!!");
- }
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement