Esempio n. 1
0
        private void btnxConn_Click(object sender, EventArgs e)
        {
            //string sChaine;
            if (txtnomBD.Text.Equals("") || txtnomuser.Text.Equals("") || txtpwd.Text.Equals(""))
            {
                MessageBox.Show(this, "Valeurs de connexion a la base des donnees manquantes !", "Missing data ...");

                txtnomuser.Focus();
            }

            else
            {
                try
                {
                    this.Cursor = Cursors.WaitCursor;


                    chaineconn = @"Data Source=" + txtnomserveur.Text + ";Initial Catalog=" + txtnomBD.Text.Trim() + ";User ID=" + txtnomuser.Text.Trim() + ";Password="******"Connection to the database successfully.", "Connected to the database", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    mainform.strconn = chaineconn;
                    mainform.usern   = this.txtnomuser.Text.Trim();
                    mainform.LockMenu(true);
                }
                catch (Exception erreur)
                {
                    MessageBox.Show(erreur.Message
                                    , ""
                                    , MessageBoxButtons.OK
                                    , MessageBoxIcon.Error);
                    mainform.xconnf = null;
                    return;
                }
                this.Cursor = Cursors.Default;
                _Myconn.Close();
                this.Close();
            }
        }
Esempio n. 2
0
        //CONNEXION A LA BASE DES DONNEES
        public void btnConnect_Click(object sender, EventArgs e)
        {
            //string sChaine;
            if (cboDatabases.Text.Trim() != "xEntryDbz")
            {
                MessageBox.Show("Base des donnees incorrect. Reessayer SVP.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cboDatabases.Focus();
            }
            else
            {
                try
                {
                    this.Cursor = Cursors.WaitCursor;


                    chaineconn = @"Data Source=" + cboServeur.Text + ";Initial Catalog=" + cboDatabases.Text.Trim() + ";User ID=" + txtUser.Text.Trim() + ";Password="******"Connection to the database successfully.", "Connected to the database", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    mainform.strconn = chaineconn;
                    mainform.usern   = this.txtUser.Text.Trim();
                    mainform.LockMenu(true);
                }
                catch (Exception erreur)
                {
                    MessageBox.Show(erreur.Message
                                    , ""
                                    , MessageBoxButtons.OK
                                    , MessageBoxIcon.Error);
                }
                this.Cursor = Cursors.Default;
                _Myconn.Close();
                this.Close();
            }
        }