1
Answer

How alex works

Rinky Jain

Rinky Jain

1y
71
1

How alex works

Answers (1)
0
Niradhip Chakraborty

Niradhip Chakraborty

NA 6.5k 527k 15y

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
Dorababu Meka

Dorababu Meka

NA 8.2k 1.2m 15y
Can i have the complete code for button click event also
0
Kirtan Patel

Kirtan Patel

NA 35k 2.8m 15y
 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());
            }
        }
    }