There is no error but why SqlDataReader returns null.
public bool CheckLogin(string uname,string passwd)
{
bool ans = false;
SqlConnection conn = new SqlConnection();
conn.ConnectionString = @"data source=localhost\SQLEXPRESS01;initial catalog = PractPro1;integrated security=true;";
conn.Open();
string strsql = "select * from UserDetails where UserName="+ uname +" and Passwd="+ passwd ;
SqlCommand cmd = new SqlCommand(strsql,conn);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
ans = true;
conn.Close();
return ans;
}
database :
create database PractPro1
go
use PractPro1
go
create table UserDetails(
UserId int identity primary key,
UserName varchar(50) not null,
Passwd varchar(50) not null,
DOB varchar(50) not null
)
go
insert into UserDetails values('neha','neha','22-08-1995')