EXIT CODE

Featured by

INTRODUCTION TO C#

Microsoft’s .NET and C# opens a whole New World of possibilities. There are many people in the industry, which see a great future to the .NE...

22/01/2018

C# login codes


Login Codes

try
            {
              

                MySqlCommand cmd = new MySqlCommand("Select * from k2sales.user where usertype=@usertype and username=@username and password=@password", connection);

                cmd.Parameters.AddWithValue("@usertype", comboBox1.Text);
                cmd.Parameters.AddWithValue("@username", UserName.Text);
                cmd.Parameters.AddWithValue("@password", Password.Text);
                connection.Open();
                MySqlDataAdapter adapt = new MySqlDataAdapter(cmd);
                DataSet ds = new DataSet();
                adapt.Fill(ds);
                connection.Close();
                int count = ds.Tables[0].Rows.Count;
                //If count is equal to 1, than show frmMain form
                if (count == 1)
                {
                    timer2.Start();
                    progressBar1.Show();
                    label7.Show();
                  

                }
                else
                {
                    label8.Show();
                    label10.Show();
                  
                    MessageBox.Show("  Login Failure..!!!! please select correct Usertype with corresponding username and password..thank you ", "login error!! ");
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

No comments:

Post a Comment