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

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 developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.