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 MySql.Data;
- using MySql.Data.MySqlClient;
- namespace WindowsFormsApp1
- {
- public partial class Form1 : Form
- {
- MySqlConnection con;
- MySqlCommand cmd;
- MySqlDataReader dr;
- public Form1()
- {
- InitializeComponent();
- con = new MySqlConnection("Server=localhost;Database=Session1;user=root;Pwd='';SslMode=none");
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- private void btnLogin_Click(object sender, EventArgs e)
- {
- string user = username.Text;
- string pass = password.Text;
- cmd = new MySqlCommand();
- con.Open();
- cmd.Connection = con;
- cmd.CommandText = "SELECT * FROM users where FirstName='" + username.Text + "' AND Password='" + password.Text + "'";
- dr = cmd.ExecuteReader();
- if (dr.Read())
- {
- MessageBox.Show("Login sucess ");
- var form2 = new Form2();
- form2.Show();
- }
- else
- {
- MessageBox.Show("Invalid Login please check username and password");
- }
- con.Close();
- }
- private void btnExit_Click(object sender, EventArgs e)
- {
- Application.Exit();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement