Hiii
i am creating login form, and all the logic is correct by me but when i run the form it
executes and inspite of i am providing the correct username and password i get the same message "Wrong login info is provided". please help me on this topic, thanx in advance! my code is as below:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace softbuyweb
{
public partial class Login : Form
{
public Login()
{
InitializeComponent();
textBox1.Select();
}
private void button1_Click(object sender, EventArgs e)
{
bool blnfound = false ;
SqlConnection myconn = new SqlConnection();
myconn.ConnectionString = "Data Source=COMPUTER_1;Initial Catalog=softbuyweb;Integrated Security=True";
myconn.Open();
SqlCommand cmd = new SqlCommand("select * from Login", myconn);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
if (dr["username"].ToString() == textBox1.Text)
{
if (dr["password"].ToString() == textBox2.Text)
{
blnfound = true;
MessageBox.Show("fine");
}
}
}
if (blnfound == false)
MessageBox.Show("Wrong login info is provided");
dr.Close();
myconn.Close();
}
}
}