public ConfigurationConnexion(
            string strNomConfig,
            string strHost,
            string strLogin,
            string strPass,
            string strBase,
            ConnexionBD.Type typeBase,
            ConnexionBD.Options structOptions )
        {
            /*this.MegaList = new List<string>();
            this.MegaList.Add("un");
            this.MegaList.Add("deux");
            this.MegaList.Add("trois");//*/
            this.strNomConfig = strNomConfig;
            this.strHost = strHost;
            this.strLogin = strLogin;
            this.strPass = strPass;
            this.strBase = strBase;
            this.typeBase = typeBase;
            //this.typeBase = new ConnexionBD.Type(typeBase.strValue, typeBase.enumerationValue, typeBase.intValue);
            this.structOptions = structOptions;

            this.version = Application.ProductVersion;
            this.dateCréation = DateTime.Now;
        }
        // Constructeur
        public ConfigurationConnexion()
        {
            this.strNomConfig = "";
            this.strHost = "";
            this.strLogin = "";
            this.strPass = "";
            this.strBase = "";
            this.typeBase = ConnexionBD.Indefini;
            //this.typeBase = new ConnexionBD.Type(ConnexionBD.Indefini.strValue, ConnexionBD.Indefini.enumerationValue, ConnexionBD.Indefini.intValue);
            this.structOptions = new ConnexionBD.Options( false, false ) ;

            this.version = Application.ProductVersion;
            this.dateCréation = DateTime.Now;
        }
Example #3
0
        private void ListerBasesDeDonnées()
        {
            ConnexionBD tempCnx = null;
            this.btListerBasesDeDonnées.Enabled = false;

            try
            {
                cbBase.Items.Clear();

                if (GestionnaireBD.Connexion == null)
                {
                    ConnexionBD.Type typeConnexion = ConnexionBD.Types[cbTypeBase.SelectedIndex];
                    ConnexionBD.Options optionsConnexion =
                        new ConnexionBD.Options(
                            cbAuthentificationIntegree.Checked,
                            cbConnexionODBC.Checked
                        );

                    if (typeConnexion.intValue == ConnexionBD.SQLServer.intValue)
                    {
                        cbBase.Text = "master";
                        tempCnx = new ConnexionSQLServer("Temporaire", optionsConnexion, tbConnectionString.Text);
                    }
                    else throw new Exception("Type de base non implémenté");
                }
                else tempCnx = GestionnaireBD.Connexion;

                List<string> listeDesStrings = tempCnx.ListeDesBases();

                if (listeDesStrings != null)
                {
                    foreach (string strNomBase in listeDesStrings)
                        cbBase.Items.Add(strNomBase);

                    cbBase.SelectedIndex = 0;
                }
                else throw new Exception("Impossible d'obtenir la liste des bases");

                if (GestionnaireBD.Connexion != tempCnx)
                    tempCnx.Close();
            }
            catch (Exception exception)
            {
                MessageBox.Show(
                    exception.Message,
                    "Erreur de connexion",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                 );
                if (tempCnx != null)
                    tempCnx.Close();
            }
            this.btListerBasesDeDonnées.Enabled = true;
            this.cbBase.DroppedDown = true;
            //this.cbBase.
        }
Example #4
0
 private void UpdateConnexionString()
 {
     if (cbTypeBase.SelectedIndex >= 0)
     {
         ConnexionBD.Type typeConnexion = ConnexionBD.Types[cbTypeBase.SelectedIndex];
         ConnexionBD.Options optionsConnexion = new ConnexionBD.Options(cbAuthentificationIntegree.Checked, cbConnexionODBC.Checked);
         tbConnectionString.Text = ConnexionBD.CreerChaineConnexion(typeConnexion, optionsConnexion, tbHost.Text, cbBase.Text, tbLogin.Text, tbPass.Text);
     }
     else tbConnectionString.Text = "Erreur....";
 }
Example #5
0
        private void Connexion()
        {
            btConnexion.Enabled = false;

            //BindingSource source = new BindingSource();
            //source.
            //SqlDataAdapter adapter = new SqlDataAdapter();
            //SqlCommandBuilder builder = new SqlCommandBuilder();

            try
            {
                ConnexionBD.Type typeConnexion = ConnexionBD.Types[cbTypeBase.SelectedIndex];
                ConnexionBD.Options optionsConnexion =
                    new ConnexionBD.Options(
                        cbAuthentificationIntegree.Checked,
                        cbConnexionODBC.Checked
                    );

                GestionnaireBD.Instance.OpenConnexion(cbBase.Text, typeConnexion, optionsConnexion, tbConnectionString.Text);

                List<string> listeDesStringsTables = GestionnaireBD.Connexion.ListeDesTables();
                List<string> listeDesStringsVues = GestionnaireBD.Connexion.ListeDesVues();

                foreach (string strNomTable in listeDesStringsTables)
                {
                    InfoTable info = new InfoTable(strNomTable, false);
                    lbListeTablesVues.Items.Add(info);
                }

                foreach (string strNomVue in listeDesStringsVues)
                {
                    InfoTable info = new InfoTable(strNomVue, true);
                    lbListeTablesVues.Items.Add(info);
                }

                lbNbTables.Text = listeDesStringsTables.Count + " tables, " + listeDesStringsVues.Count + " vues";

                /*AfficherListeDesElementsBD(
                    true,
                    true,
                    cbMinLignes.Checked,
                    (int)nuMinLignes.Value,
                    cbMaxLignes.Checked,
                    (int)nuMaxLignes.Value,
                    cbTablesAvecErreur.Checked);///*/
                if( lbListeTablesVues.Items.Count > 0 )
                    lbListeTablesVues.SetSelected(0, true);
                lbListeTablesVues.Focus();

                // Activation des boutons de l'interface
                btConnexion.Enabled = false;
                btDeconnexion.Enabled = true;

                labelHost.Enabled = false;
                labelLogin.Enabled = false;
                labelPass.Enabled = false;
                labelBase.Enabled = false;

                tbHost.Enabled = false;
                tbLogin.Enabled = false;
                tbPass.Enabled = false;
                cbBase.Enabled = false;

                cbConfig.Enabled = false;
                cbTypeBase.Enabled = false;
                cbAuthentificationIntegree.Enabled = false;
                cbConnexionODBC.Enabled = false;

                gbTables.Enabled = true;
                gbBD.Enabled = true;
                btExecuterRequete.Enabled = true;

                btExtraireTouteLaBD.Enabled = true;
                btImporterTouteLaBD.Enabled = true;

                cbMinLignes.Checked = false;
                cbMaxLignes.Checked = false;
                nuMinLignes.Enabled = false;
                nuMaxLignes.Enabled = false;
                cbTablesAvecErreur.Checked = false;

                this.Text = cbBase.Text + " (" + tbHost.Text + ") - Import Export Flash Générique - v" + Application.ProductVersion.Substring(0, 3);
                this.gbTables.Text = "Liste des tables et vues de " + cbBase.Text;
                //this.gbBD.Text = "Base de données " + cbBase.Text;

                persisterFormAssociation = false;
                persisterFormImportDeMasse = false;
                btListerBasesDeDonnées.Enabled = false;

                tabCommandes.SelectedIndex = 2;
            }
            catch (Exception exception)
            {
                // Gestion des erreurs
                Deconnexion();

                MessageBox.Show(
                    exception.Message,
                    "Erreur de connexion",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                 );
            }
        }