Jump to content

Database Table

- - - - -

  • Please log in to reply
1 reply to this topic

#1
shyamenk

shyamenk

    Newbie

  • Members
  • PipPip
  • 11 posts
how to get last row in mysql database table... using MAX query


I try


CODE:::::::


private int GetNewId()

   

      {

          

   

      int newID = 0;


      str = "SELECT MAX(Usedphone_Id) FROM usedphonedtls";

   

      //create connection,

   

      //create command

   

      //use sqlDataReader to read the last inserted id

   

      newID = (int)reader[0];

   

      //increase it by 1 to get the new number (id):

  

      return newID++;

  

      }





I cant understand


  newID = (int)reader[0];

Edited by Roger, 25 February 2011 - 03:51 AM.
added code block


#2
shyamenk

shyamenk

    Newbie

  • Members
  • PipPip
  • 11 posts
i got the answere


 str = "SELECT MAX(Usedphone_Id) FROM usedphonedtls";

            int s = objcmd.returnvalue(str);

Edited by Roger, 25 February 2011 - 03:52 AM.
added code block





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users