public partial class Login : Form
{
SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;Initial Catalog=Library_management_system;Integrated Security=True;User Instance=True");
int count = 0;
public Login()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
SqlCommand cmd=con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * from Library_person where usernaem='"+textBox1.Text+"' and password='"+textBox2.Text+"'";
cmd.ExecuteNonQuery();
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
count=Convert.ToInt32(dt.Rows.Count.ToString());
if(count==0)
{
MessageBox.Show("username password does not match");
}
else
{
this.Hide();
mdi_user mu = new mdi_user();
mu.Show();
}
}
private void Login_Load(object sender, EventArgs e)
{
if(con.State==ConnectionState.Open)
{
con.Close();
}
con.Open();
}
}