Firstly using
select 'Max_No'=max(ProductID) from Product_Details
is unsafe in multi-user environments, and not efficient on larger tables.
You would be better off defining a column on your table as an auto-increment ID ... see
msdn documentation here[
^]
As to your problem with the 2nd Product ID with the code that you have ... do you actually update the database with each new ID ... if not then your select statement is always going to return zero.