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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
| uses
inifiles,
System.Drawing,
System.Collections,
System.Collections.Generic,
System.Linq,
System.Windows.Forms,
System.ComponentModel,
System.Configuration;
type
/// <summary>
/// Summary description for fm_connectBDD.
/// </summary>
fm_connectBDD = partial class(System.Windows.Forms.Form)
private
method kryptonButton1_Click(sender: System.Object; e: System.EventArgs);
protected
method Dispose(aDisposing: Boolean); override;
public
constructor;
end;
implementation
{$REGION Construction and Disposition}
constructor fm_connectBDD;
begin
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
end;
method fm_connectBDD.Dispose(aDisposing: Boolean);
begin
if aDisposing then begin
if assigned(components) then
components.Dispose();
//
// TODO: Add custom disposition code here
//
end;
inherited Dispose(aDisposing);
end;
{$ENDREGION}
method fm_connectBDD.kryptonButton1_Click(sender: System.Object; e: System.EventArgs);
Var
FichierIni : Tinifiles;
begin
mySqlConnection1.Host := kryptonTextBox1.Text;
mySqlConnection1.Port := System.Convert.ToInt32(kryptonTextBox2.Text);
mySqlConnection1.Database := 'thermotracer';
mySqlConnection1.UserId := 'root';
mySqlConnection1.Password := 'oo';
try
mySqlConnection1.Open();
MessageBox.Show("La connexion avec la base de données a réussie");
Close();
except on ex:Devart.Data.MySql.MySqlException do
MessageBox.Show( "Erreur de connexion: " + ex.Message );
end;
(*//Ouvre le fichier ini (si il n'éxiste pas, le fichier est alors créé)
FichierIni:=TIniFile.Create(ChangeFileExt( Application.Exename,'.ini'));
//Enregistre le nom du serveur et du numero de port
FichierIni.WriteString('Parametre','Serveur',kryptonTextBox1.Text);
FichierIni.WriteInteger('Parametre','TCP Port',kryptonTextBox2.Text);
//Détruit l'objet
FichierIni.Free;
Close; *)
end;
end. |
Partager