Click here to Skip to main content
15,901,284 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
dear all of you firstly i submitted my code what is used in login 3 tire architecture.

username - admin and pwd is : santosh in my database. tbluser then i send to you all code.
i run this project and submit username and password click on login button generate error:

An expression of non-boolean type specified in a context where a condition is expected, near 'santosh'.




DL Code IS :
----------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

namespace DL
{

public class clsDLayer
{

SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Connection"].ConnectionString.ToString());
public DataSet LoginToSystem(string UserName, string Passsword)
{
con.Open();
SqlDataAdapter da = new SqlDataAdapter("Select * from tbluser where UserName='" + UserName.ToString() + "' and '" + Passsword.ToString() + "'", con);
DataSet ds = new DataSet();
da.Fill(ds);

return ds;

if (con.State == ConnectionState.Open)
{
con.Close();
}
}
}
}
-----------------------------
BL CODE lS :
-----------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DL;
namespace BL
{
public class clsBLayer
{


public DataSet LoginToSystem(string UserName, string Password)
{
DataSet ds = obj2.LoginToSystem(UserName,Password);
return ds;

}

}
}

-------------------------
Login.aspx.cs Code Is:
-------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BL;

public partial class Login : System.Web.UI.Page
{


protected void Page_Load(object sender, EventArgs e)
{

}


protected void Button1_Click(object sender, EventArgs e)
{
clsBLayer c2 = new clsBLayer();

DataSet ds = new DataSet();
ds = c2.LoginToSystem(txtUserName.Text,txtPwd.Text);

if (ds.Tables[0].Rows.Count != 0)
{
Session["UserName"] = ds.Tables[0].Rows[0][1].ToString();
Response.Redirect("~/Admin/AdminDashboard.aspx");
}
else
{
Response.Write("Sorry! Incorrect Username and Password.");
}
}

protected void btnClear_Click(object sender, EventArgs e)
{
clear();
}

protected void clear() {

txtUserName.Text = "";
txtPwd.Text = "";
}

}


thank your in advance all of you..
Posted
Updated 6-Aug-13 20:05pm
v2

1 solution

Your query is wrong

Select * from tbluser where UserName='" + UserName.ToString() + "' and '" + Passsword.ToString()
should be
Select * from tbluser where UserName='" + UserName.ToString() + "' and Password = '" + Passsword.ToString()
 
Share this answer
 
Comments
santsho kumar 7-Aug-13 2:22am    
Thank your sir my problem is remove used your query thank you very much..again

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900