using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
string connectionString;
connectionString =("Data Source=INTRANETSERVER1;User ID=sa;Initial Catalog=HrData");
SqlConnection myConnection = new SqlConnection(connectionString);
SqlDataAdapter ad = new SqlDataAdapter("SELECT * FROM BMauthority1", myConnection);
DataSet ds = new DataSet();
ad.Fill(ds,"pwd");
GridView1.DataSource = ds;
GridView1.DataBind();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
try
{
string uname = TextBox1.Text; //Get the username from the control
string password = TextBox2.Text; //get the Password from the control
bool flag = AuthenticateUser(uname, password);
if (flag == true)
{
Response.Write("Successfult login");
Response.Redirect("Default2.aspx");
}
}
catch (Exception)
{
Response.Write("Incorrect user name or password");
}
}
private bool AuthenticateUser(string uname, string password)
{
bool bflag = false;
string connectionString;
connectionString = ("Data Source=INTRANETSERVER1;User ID=sa;Initial Catalog=HrData");
SqlConnection myConnection = new SqlConnection(connectionString);
SqlDataAdapter ad = new SqlDataAdapter("SELECT * FROM BMauthority1", myConnection);
DataSet ds = new DataSet();
ad.Fill(ds);
if (ds != null)
{
if( == TextBox1.Text )
{
bflag = true;
}
}
return bflag;
}
}
i want to check database column value with textbox1 then,
what should i write in if condition?