0

This is not working, what I wanted to do is to check if there's an active account before I log in,if so, then there's a prompt that will pop up to tell me that there's still an active account that needs to log out.. TIA

bool isActive = false;

            string query = "SELECT fld_Status FROM tbluseraccount WHERE fld_UserName = ?username AND fld_UserPassword = ?password";
            MySqlCommand cmd = new MySqlCommand(query,dba.initConnection());
            cmd.Parameters.AddWithValue("?username", txtUserName.Text);
            cmd.Parameters.AddWithValue("?password", txtPassword.Text);
            if (dba.connection.State == ConnectionState.Closed)
            {
                dba.connection.Open();
                using (MySqlDataReader mdr = cmd.ExecuteReader())
                {

                    if (mdr.HasRows)
                    {
                        while (mdr.Read())
                        {

                            isActive = (bool)mdr[0];
                        }

                    }

                }
                dba.closeConnection();
            }
            if (dba.connection.State == ConnectionState.Closed)
            {
                dba.connection.Open();
                using (MySqlDataReader dr = cmd.ExecuteReader())
                {
                    if (isActive == true)
                    {
                        MessageBox.Show("isActive");
                    }
                    else
                    {
                    //log in successfully!
                    }

                }

            }

Edited by vin_1

2
Contributors
1
Reply
12
Views
1 Month
Discussion Span
Last Post by rproffitt
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.