Trying to get the last row inserted from a Excel sheet. The sheet is called clientes.

I have

id, name, description

Since ID is auto incremental, I can sort by ID:

My idea is:

oledbcmd = "Select top (1) * From [CLIENTES$] ORDER BY id desc";

but it does not work. Any tips?

You just want the last row? If so, you can do a SELECT command and order everything in ascending or descending order. That will show everything in order.

If you just want one item, you can add a WHERE clause somewhere in there such as

SELECT * FROM (table_name) WHERE (something) (<, > , =) ORDER BY (Firstname, Lastname, whatever you want) asc(if you want ascending) desc(if you want descending)

remove the parentheses and put in the names and values of what you want.

Otherwise, you can to

SELECT TOP 100 PERCENT * FROM (table_name)

That will go by the id numbers by default.

The article starter has earned a lot of community kudos, and such articles offer a bounty for quality replies.