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?

Recommended Answers

I read and tried this at
There was not parenstheses around 1.

Jump to Post

All 3 Replies

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.

IF someone has similar problem, use Zetexcel.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.