Beispiel #1
0
        public string get_password(string userid)
        {
            MySqlConnection connection = Cl_MySQL.getMySQLConnection();

            Cl_MySQL.OpenMySQLConnection(connection);

            MySqlParameter param = new MySqlParameter();

            param.ParameterName = "@userid";
            param.Value         = userid;

            MySqlCommand command = connection.CreateCommand();

            command.CommandText = "SELECT Passwordtext FROM password WHERE UID = @userid  ";
            command.Parameters.Add(param);

            MySqlDataReader reader;

            reader = command.ExecuteReader();

            while (reader.Read())
            {
                this.password = reader.GetValue(0).ToString();
            }

            Cl_MySQL.CloseMySQLConnection(connection);


            return(this.password);
        }
Beispiel #2
0
        private void btn_sqlconnection_Click(object sender, EventArgs e)
        {
            try
            {
                connection = Cl_MySQL.getMySQLConnection("localhost", "root", "", "fit-raspi");
                Cl_MySQL.OpenMySQLConnection(connection);

                MessageBox.Show("You are connected to the database: FIT-RASPI");
            }
            catch
            {
                MessageBox.Show("Fail to connect to database");
            }
        }