0
For button Click you may refer following code:
bool blnFound = false;
SqlConnection sqlCon = null;
sqlCon = new SqlConnection(ConfigurationManager.AppSettings["con"].ToString());
sqlCon.Open();
SqlCommand cmd = new SqlCommand("select * from Users where", sqlCon);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
//validating user name
if (dr["usr_vch_Name"].ToString() == cboUserName.Value)
{
// validating password
if(dr["usr_vch_Password"].ToString()).ToString() == txtPassword.Text)
{
blnFound = true;
// User validated successfully, code redirect to other pages
}
}
}
0
Can i have the complete code for button click event also
0
If i Have table With Column 'username'
Then Code Will be Like Below
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True");
con.Open();
SqlCommand comm = new SqlCommand("select Username From Users", con);
SqlDataReader reader = comm.ExecuteReader();
while (reader.Read())
{
ddlUsers.Items.Add(reader["Username"].ToString());
}
}
}