MySql.Data.MySqlClient.MySqlDataReader.Read C# (CSharp) Method

Read() public method

Advances the MySqlDataReader to the next record.
public Read ( ) : bool
return bool
    public override bool Read()
    {
      if (!isOpen)
        Throw(new MySqlException("Invalid attempt to Read when reader is closed."));
      if (resultSet == null)
        return false;

      try
      {
        return resultSet.NextRow(commandBehavior);
      }
      catch (TimeoutException tex)
      {
        connection.HandleTimeoutOrThreadAbort(tex);
        throw; // unreached
      }
      catch (System.Threading.ThreadAbortException taex)
      {
        connection.HandleTimeoutOrThreadAbort(taex);
        throw;
      }
      catch (MySqlException ex)
      {
        if (ex.IsFatal)
          connection.Abort();

        if (ex.IsQueryAborted)
        {
          throw;
        }

        throw new MySqlException(Resources.FatalErrorDuringRead, ex);
      }
    }

Usage Example

Ejemplo n.º 1
2
        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='******';", 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='******';", 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:
        }
All Usage Examples Of MySql.Data.MySqlClient.MySqlDataReader::Read