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); }
private void button1_Click(object sender, EventArgs e) { try { Cl_MySQL.CloseMySQLConnection(connection); MessageBox.Show("You are disconnected from the database!"); } catch { MessageBox.Show("No database-connection exists!"); } }
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"); } }