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 test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
SqlConnection cn = new SqlConnection("server = localhost; user id = root; password=admin1234; database = test");
cn.Open();
SqlCommand cmd = new SqlCommand("SELECT * FROM users where username = '" + txtusername.Text + "', and passw =' " + txtpassword.Text + "'", cn);
SqlDataReader dr;
dr = cmd.ExecuteReader();
int count = 0;
while (dr.Read())
{
count += 1;
}
if (count == 1)
{
MessageBox.Show("OK");
Form2 f2 = new Form2();
f2.Show();
}
else if (count > 0)
{
MessageBox.Show("Duplicate username and password");
}
{
MessageBox.Show("username or password note correct");
}
txtusername.Clear();
txtpassword.Clear();
}
}
}

Chetan RanpariyaRank #1,852 · 801 reputationPosted Jan 17, 2017, 8:07 AM EST
Chetan RanpariyaRank #1,852 · 801 reputationPosted Jan 17, 2017, 8:13 AM EST
Amit GuptaRank #190 · 12.8K reputationPosted Jan 17, 2017, 7:36 AM EST
Enzo Enzo23 reputationPosted Jan 17, 2017, 7:45 AM EST
Amit GuptaRank #190 · 12.8K reputationPosted Jan 17, 2017, 8:17 AM EST
Chetan RanpariyaRank #1,852 · 801 reputationPosted Jan 17, 2017, 9:58 AM EST
Enzo Enzo23 reputationPosted Jan 17, 2017, 10:49 AM EST
Amit GuptaRank #190 · 12.8K reputationPosted Jan 17, 2017, 10:56 AM EST
Enzo Enzo23 reputationPosted Jan 17, 2017, 9:56 AM EST