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!
                    }

                }

            }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.