... retreve the maximum no of rows from database then u can add +1 then u can get the result.
This won't work in most DBs that have had a row deleted from them. For example, say you have a DB with 10 rows added to it initially. Your highest auto increment ID is 10 and you have 10 rows. Now, if you delete a row you have only 9 rows but still a highest auto increment field of 10.