0

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?

3
Contributors
2
Replies
14
Views
9 Months
Discussion Span
Last Post by TheFearful
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.