Re: how can i move to the last record of recordset



Am Mon, 04 Dec 2006 05:28:09 -0800 schrieb ashwinijain:

i have one table in MS. Access in which i am storing company details.
i want to create an unique company id for each company.
so i want to aceess the last row in the table to generate next id
I am using last() method but its throwing sqlexception.
rs=stat1.executeQuery("Select Company_id from Company ");

// Code
if(rs!=null)
{
rs.last();
no=rs.getInt(1) + 1;
}
else
no=1;



you could use "order by company_id asc" in the sql-statement and take
the first row of the resultset.

concerning the Exception: are there any records in the resultset ?


.