1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| ///////////////////////////////:
/// La Class//////////////////
public class DataBase
{
private string _Serveur;
private string _Base;
private string _Login;
private string _Pass;
private MySQLConnection _conn;
// le constructeur
public DataBase()
{
_Serveur="localhost";
_Base="maBase";
_Login="root";
_Pass="";
try {
_conn = new MySQLConnection( new MySQLConnectionString(_Serveur,_Base,_Login,_Pass).AsString );
_conn.Open();
}// fin try
catch(Exception)
{
MessageBox.Show("la connexion à ecouhé","Erreur" , System.Windows.Forms.MessageBoxButtons.OK,System.Windows.Forms.MessageBoxIcon.Error);
}// fin catch
}// fin constructeur
//Retourne la connexion active
public MySQLConnection Connection()
{
return _conn;
}
//Destructeur
~DataBase()
{
_conn.Close();
}
}
//////////////////////
////fin Class////////// |
Partager