当前位置: 首页>>代码示例>>C#>>正文


C# MySqlDataReader.Close方法代码示例

本文整理汇总了C#中MySql.Data.MySqlClient.MySqlDataReader.Close方法的典型用法代码示例。如果您正苦于以下问题:C# MySqlDataReader.Close方法的具体用法?C# MySqlDataReader.Close怎么用?C# MySqlDataReader.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MySql.Data.MySqlClient.MySqlDataReader的用法示例。


在下文中一共展示了MySqlDataReader.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IsNameExist

 public bool IsNameExist(string name)
 {
 string strSql="select * from account where accountName='"+name.Trim()+"'";
     try{
         sdr=db.GetDataReader(strSql);
         sdr.Read();
         if(sdr.HasRows)
         {
           sdr.Close();
          return true;
         }
         else
         {
         sdr.Close();
         return false;
         }
      
     }
     catch(Exception e)
     {
     
     }
     finally
     {
     sdr.Close();
     }
     return true;
 }
开发者ID:hongbao66,项目名称:ERP,代码行数:28,代码来源:AccountMgr.cs

示例2: initialisation

 // Initialise la fenêtre
 private void initialisation()
 {
     try
     {
         if (Global.Connection.State != ConnectionState.Open)
         {
             // Ouverture de la connexion
             Global.Connection.Open();
         }
         MySqlCommand cmd = new MySqlCommand("SELECT * FROM utilisateur WHERE idUtilisateur = '" + Global.userId + "'", Global.Connection);
         rd = cmd.ExecuteReader();
         rd.Read();
         labelPrenom.Text = (string)rd["prenom"];
         labelNom.Text = (string)rd["nom"];
         labelMail.Text = (string)rd["mail"];
         labelNaissance.Text = String.Format("{0:dd/MM/yyyy}", rd["dateNaissance"]);
         labelSexe.Text = (string)rd["sexe"];
         textBoxLogin.Text = (string)rd["login"];
         pictureBoxAvatar.Load(System.Windows.Forms.Application.StartupPath + @"\Avatar\" + (string)rd["avatar"]);
         avatarPath = System.Windows.Forms.Application.StartupPath + @"\Avatar\" + (string)rd["avatar"];
         rd.Close();
         // Fermeture de la connexion
         //Global.Connection.Close();
     }
     catch (MySqlException)
     {
         MessageBox.Show("Une erreur est survenue. Impossible de contiuer.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
         rd.Close();
         Global.Connection.Close();
     }
 }
开发者ID:nico06530,项目名称:projet_ecole_localcar_user,代码行数:32,代码来源:frmInformation.cs

示例3: btnValider_Click

 // Changement du mot de passe
 private void btnValider_Click(object sender, EventArgs e) {
     // Si tout les champs renseignés
     if (txtAncMdp.Text != "" && txtCnfNouvMdp.Text != "" && txtNouvMdp.Text != "") {
         // ---------- Vérification des informations rentrées ---------------           
         // Vérification que nouveau mot de passe + confirmation soient identiques
         if (txtNouvMdp.Text == txtCnfNouvMdp.Text) {
             // Vérification de la longueur du nouveau mot de passe
             if (txtNouvMdp.TextLength >= Global._MIN_CARAC_PWD) {
                 // Vérification du mot de passe actuel
                 try {
                     cmd = new MySqlCommand("SELECT count(*) FROM utilisateur WHERE idUtilisateur = '" + Global.userId + "' and password = PASSWORD(@pwd)", Global.Connection);
                     MySqlParameter pMdp = new MySqlParameter("@pwd", MySqlDbType.Text);
                     pMdp.Value = txtAncMdp.Text;
                     cmd.Parameters.Add(pMdp);
                     cmd.Prepare();
                     rd = cmd.ExecuteReader();
                     rd.Read();
                     // Si ancien mot de passe OK
                     if (rd.GetInt16(0) == 1) {
                         rd.Close();
                         // MAJ du mot de passe
                         cmd = new MySqlCommand("UPDATE utilisateur SET password = PASSWORD(@pwd) WHERE idUtilisateur = '" + Global.userId + "'", Global.Connection);
                         MySqlParameter pNouvMdp = new MySqlParameter("@pwd", MySqlDbType.Text);
                         pNouvMdp.Value = txtNouvMdp.Text;
                         cmd.Parameters.Add(pNouvMdp);
                         cmd.Prepare();
                         cmd.ExecuteNonQuery();
                         MessageBox.Show("Votre mot de passe a bien été modifié ! ", "Succès", MessageBoxButtons.OK, MessageBoxIcon.Information);
                         rd.Close();
                         // Retour à l'écran principal
                         this.Close();
                     } else {
                         MessageBox.Show("Votre mot de passe actuel est incorrect. Veuillez recommencer.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                         txtAncMdp.Text = "";
                         rd.Close();
                     }
                 } catch (MySqlException) {
                     MessageBox.Show("Une erreur est survenue. Le mot de passe n'a pas été changé.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     rd.Close();
                 }
             } else {
                 MessageBox.Show("Le nouveau mot de passe est trop petit : minimum " + Global._MIN_CARAC_PWD + " caractères.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 txtNouvMdp.Text = "";
                 txtCnfNouvMdp.Text = "";
             }
         } else {
             MessageBox.Show("Le nouveau mot de passe et sa confirmation ne correspondent pas.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
             txtNouvMdp.Text = "";
             txtCnfNouvMdp.Text = "";
         }
     } else {
         MessageBox.Show("Veuillez renseigner tous les champs.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
开发者ID:nico06530,项目名称:projet_ecole_localcar_user,代码行数:55,代码来源:frmChangementMdp.cs

示例4: init

        /// <summary>
        /// Initialisation de la fenêtre
        /// </summary>
        private void init() {
            // Résa en cours 
            try {
                requete = "SELECT idEmprunt, categorie, marque, modele, matricule, vehicule.idVehicule FROM emprunt INNER JOIN vehicule ON emprunt.idVehicule = vehicule.idVehicule "
                    + " INNER JOIN categorievehicule ON vehicule.idCategorieVehicule = categorievehicule.idCategorieVehicule WHERE idUtilisateur = " + Global.userId + " AND valide = 1 AND rendu = 0";
                MySqlCommand cmd = new MySqlCommand(requete, Global.Connection);
                rd = cmd.ExecuteReader();
                // On ajoute chaque ligne à la dgv
                dgvEnCours.AllowUserToAddRows = true;
                while (rd.Read() != false) {
                    row = (DataGridViewRow)dgvEnCours.Rows[0].Clone();
                    row.Cells[0].Value = rd["idEmprunt"];
                    row.Cells[1].Value = rd["idVehicule"];
                    row.Cells[2].Value = rd["categorie"];
                    row.Cells[3].Value = rd["marque"];
                    row.Cells[4].Value = rd["modele"];
                    row.Cells[5].Value = rd["matricule"];
                    dgvEnCours.Rows.Add(row);
                }
                dgvEnCours.AllowUserToAddRows = false;
                rd.Close();
            } catch (MySqlException) {
                MessageBox.Show("Une erreur est survenue. Impossible de contiuer.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                rd.Close();
            }

            // Résa en attente
            try {
                requete = "SELECT idEmprunt, categorie, marque, modele, matricule, vehicule.idVehicule FROM emprunt INNER JOIN vehicule ON emprunt.idVehicule = vehicule.idVehicule "
                    + " INNER JOIN categorievehicule ON vehicule.idCategorieVehicule = categorievehicule.idCategorieVehicule WHERE idUtilisateur = " + Global.userId + " AND valide = 0 AND rendu = 0";
                MySqlCommand cmd = new MySqlCommand(requete, Global.Connection);
                rd = cmd.ExecuteReader();
                // On ajoute chaque ligne à la dgv
                dgvEnAtt.AllowUserToAddRows = true;
                while (rd.Read() != false) {
                    row = (DataGridViewRow)dgvEnAtt.Rows[0].Clone();
                    row.Cells[0].Value = rd["idEmprunt"];
                    row.Cells[1].Value = rd["idVehicule"];
                    row.Cells[2].Value = rd["categorie"];
                    row.Cells[3].Value = rd["marque"];
                    row.Cells[4].Value = rd["modele"];
                    row.Cells[5].Value = rd["matricule"];
                    dgvEnAtt.Rows.Add(row);
                }
                dgvEnAtt.AllowUserToAddRows = false;
                rd.Close();
            } catch (MySqlException) {
                MessageBox.Show("Une erreur est survenue. Impossible de contiuer.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                rd.Close();
            }
        }
开发者ID:nico06530,项目名称:projet_ecole_localcar_user,代码行数:54,代码来源:frmReservationEnCours.cs

示例5: getMACPass

 public string getMACPass(string email)
 {
     string query = string.Format("SELECT u.macpass from users u WHERE u.email='{0}';", email);
     cmd = new MySqlCommand(query, conn);
     read = cmd.ExecuteReader();
     if (read.Read())
     {
         string result = read.GetString(0);
         read.Close();
         return result;
     }
     read.Close();
     return "No records exist";
 }
开发者ID:cbguder,项目名称:practises,代码行数:14,代码来源:DatabaseConnection.cs

示例6: getAnswers

 public string getAnswers(string email)
 {
     string query = "SELECT u.semisecret1 from users u WHERE u.email='" + email + "';";
     cmd = new MySqlCommand(query, conn);
     read = cmd.ExecuteReader();
     if (read.Read())
     {
         string result = read.GetString(0);
         read.Close();
         return result;
     }
     read.Close();
     return email + ": No records exist";
 }
开发者ID:cbguder,项目名称:practises,代码行数:14,代码来源:DatabaseConnection.cs

示例7: initialisation

 // Initialise la fenêtre
 private void initialisation() {
     try {
         MySqlCommand cmd = new MySqlCommand("SELECT * FROM utilisateur WHERE idUtilisateur = '" + Global.userId + "'", Global.Connection);
         rd = cmd.ExecuteReader();
         rd.Read();
         rd.Close();
         // MAJ des infos de connexion
         cmd = new MySqlCommand("UPDATE utilisateur SET dateDerniereConnexion = now() WHERE idUtilisateur = '" + Global.userId + "'", Global.Connection);
         cmd.ExecuteNonQuery();
         rd.Close();
     } catch (MySqlException) {
         MessageBox.Show("Une erreur est survenue. Impossible de contiuer.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
         rd.Close();
     }
 }
开发者ID:nico06530,项目名称:projet_ecole_localcar_user,代码行数:16,代码来源:frmPrinicpale.cs

示例8: DisposeMysql

 public static void DisposeMysql(MySqlDataReader obj)
 {
     if (obj != null)
     {
         obj.Close();
     }
 }
开发者ID:samfromdeath,项目名称:CSharpServer,代码行数:7,代码来源:Database.cs

示例9: LoadSector

 public List<Sector> LoadSector()
 {
     try
     {
         using (MySqlConnection cn = new MySqlConnection((clsCon=new Connection(this.user)).Parameters()))
         {
             listSec = new List<Sector>();
             cn.Open();
             sql = "select * from asada.view_sectores";
             cmd = new MySqlCommand(sql, cn);
             reader = cmd.ExecuteReader();
             while (reader.Read())
             {
                 sec = new Sector();
                 sec.Code = reader.GetString(0);
                 sec.Consecutive = reader.GetInt32(1);
                 sec.Description = reader.GetString(2);
                 listSec.Add(sec);
             }
             reader.Close();
             return listSec;                    
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
开发者ID:MBLopez,项目名称:Asada07,代码行数:28,代码来源:SectorDAO.cs

示例10: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        topics_ids = new ArrayList();

        dbConnection = new MySqlConnection(ConfigurationManager.AppSettings["ConnectionString"].ToString());
        dbConnection.Open();

        slctTopics = new MySqlCommand("SELECT t_id FROM topics", dbConnection);
        dReaderTopics = slctTopics.ExecuteReader();

        while (dReaderTopics.Read())
        {
            topics_ids.Add(dReaderTopics[0].ToString());
            counter++;
        }

        dReaderTopics.Close();
        slctTopics.Dispose();

        while (i < counter)
        {
            updtTopicsNumberOfVideos = new MySqlCommand("UPDATE topics SET t_nb_videos=(SELECT count(*) FROM videos WHERE t_id=" + topics_ids[i].ToString() + ") WHERE t_id=" + topics_ids[i].ToString(), dbConnection);
            updtTopicsNumberOfVideos.ExecuteNonQuery();
            updtTopicsNumberOfVideos.Dispose();
            i++;
        }
    }
开发者ID:mrhanti,项目名称:getiteasy,代码行数:27,代码来源:Update.aspx.cs

示例11: CheckNameAndPasswd

       //when check name and password, get the user's information
       public PropertyClass CheckNameAndPasswd(string name,string password)
       {
           PropertyClass accountClass=null;


       string strSql="select * from account where accountName='"+name.Trim()+"' and accountPassword='"+password.Trim()+"'";
        try{
           sdr=db.GetDataReader(strSql);
            sdr.Read();
            if(sdr.HasRows)
            {
            accountClass=new PropertyClass();
            accountClass.UserId=sdr.GetInt32("id");
            accountClass.AccountName=name.Trim();
            accountClass.AccountPassword=password.Trim();
            accountClass.Email=sdr["email"].ToString();
            accountClass.Job=sdr.GetInt32("job");;
            accountClass.Superviser=sdr.GetInt32("superviser");
            }
        }
           catch(Exception ex)
        {
           
          }
        finally
        {
            sdr.Close();
        }
          return accountClass; 
      
       }
开发者ID:hongbao66,项目名称:ERP,代码行数:32,代码来源:AccountMgr.cs

示例12: getNextInfoHashes

        public List<string> getNextInfoHashes(int nofInfohashes)
        {
            List<String> lResult = new List<String>();
            lock (Program.dbLock)
            {
                // Get oldest torrent
                command.CommandText = "SELECT  `infohash`,`id` FROM  `torrents45` ORDER BY updated ASC LIMIT "
                    + nofInfohashes.ToString() + ";";
                command.CommandTimeout = 60000;
                connection.Open();

                reader = command.ExecuteReader();
                if (!reader.HasRows) return null;
                while (reader.Read())
                {
                    lResult.Add(reader.GetString("infohash"));
                }

                reader.Close();
                connection.Close();
                connection.Open();

                command.CommandText = "UPDATE `torrents45` SET updated = CURRENT_TIMESTAMP WHERE infohash = '" + lResult[0] + "' OR ";
                for (int i = 1; i < lResult.Count-1; i++)
                {
                    command.CommandText += "infohash = '" + lResult[i] + "' OR ";
                }
                command.CommandText += "infohash = '" + lResult[lResult.Count-1] + "';";
                command.CommandTimeout = 60000;
                command.ExecuteNonQuery();
                connection.Close();
            }
            return lResult;
        }
开发者ID:supertanglang,项目名称:DHTCrawler-1,代码行数:34,代码来源:MySQL.cs

示例13: BuscarIdPlanoDeMarketing

        //funcionando
        public int BuscarIdPlanoDeMarketing(int IdPlano)
        {
            try
            {
                string QueryPesquisarIdSumario = "select * from planodemarketing where [email protected];";
                int idSumario = 0;

                Dal.ConectarBanco();
                ComandoPesquisarIdPlanoDeMarketing = new MySqlCommand(QueryPesquisarIdSumario);
                ComandoPesquisarIdPlanoDeMarketing.Connection = Dal.Conn;
                ComandoPesquisarIdPlanoDeMarketing.Parameters.AddWithValue("@IdPlano", IdPlano);

                ReaderPEsquisarIdPlanoDeMarketing = ComandoPesquisarIdPlanoDeMarketing.ExecuteReader();
                while (ReaderPEsquisarIdPlanoDeMarketing.Read())
                {
                    idSumario = int.Parse(ReaderPEsquisarIdPlanoDeMarketing["id"].ToString());
                }
                return idSumario;

            }
            catch
            {
                int idSumario = 0;
                return idSumario;

            }
            finally
            {
                ReaderPEsquisarIdPlanoDeMarketing.Close();
                Dal.FecharConexao();
            }
        }
开发者ID:diegolinkk,项目名称:SimuladorDeNegocios,代码行数:33,代码来源:PlanoDeMarketingDAL.cs

示例14: Login

        public static void Login(string username, string passhash)
        {
            if (Validate(username, passhash))
            {
                time = string.Format("{0:yyyy.MM.dd 0:HH:mm:ss tt}", DateTime.Now);

                rdr = new MySqlCommand("SELECT lastin FROM login WHERE username='" + username + "';", conn).ExecuteReader();
                while (rdr.Read()) {
                    Console.WriteLine("User's last sign in was: " + rdr["lastin"]);
                }
                rdr.Close();

                new MySqlCommand("UPDATE login SET lastin='" + time + "' WHERE username='" + username + "';", conn).ExecuteNonQuery();

            }
            Console.WriteLine("HHHHhhhh");

            //TODO:
            //
            //If the username exists, check that the password hash matches.
            //
            //If the username does not exist, be like "No user found".
            //
            //Else, If the password hash matches, Sign in.
            //Set the current player to active
            //forward/bind socket to control an Object?
            //Note the timestamp and IP of the login in the database
            //Send all of the necessary information back to the client:
        }
开发者ID:SleepyViking,项目名称:DirtyWater,代码行数:29,代码来源:Meta.cs

示例15: Login

 public int Login(TextBox utilizador, TextBox password)
 {
     Conetar();
     int valor = 0;
     string query = "SELECT * FROM conta WHERE utilizador='" + utilizador.Text + "' AND password='" + password.Text + "';";
     _cmdDataBase = new MySqlCommand(query, _conDataBase);
     try
     {
         _conDataBase.Open();
         _myReader = _cmdDataBase.ExecuteReader();
         while (_myReader.Read())
         {
         }
         if (_myReader.HasRows)
         {
             MessageBox.Show("Login Correto");
             valor = 1;
         }
         else
         {
             MessageBox.Show("Login Incorreto! Volte a Introduzir as suas Credenciais");
             valor = 0;
         }
         _myReader.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     return valor;
 }
开发者ID:hferreira94,项目名称:Ideial---DIS,代码行数:31,代码来源:DataBase.cs


注:本文中的MySql.Data.MySqlClient.MySqlDataReader.Close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。