-1

In my code, I am first inserting some form inputs into one DB table, table A. That works just fine.

There is an auto incrementing cID column of type int in table A which increments by 1 with each entry.

Once the form inputs are entered into A, I want to then get the cID value for that entry and save it as a dim.

How would I go about doing that?

I thought about doing -

dim latest
set latest = dbConn.execute("select @@identity from A")

but that does not work.

What should I do to get the cID for the submission that was just entered and store it in dim latest?

I tried looking at other stackoverflow posts they weren't of much help. If you find something that may help me or know what I should do, please let me know.

Thanks

  • 1
    This is much less an ASP Classic/ADO question than *"How to get the last inserted ID from SQL Server"*, and that question has been answered before (see linked duplicate): Use `SCOPE_IDENTITY()`. – Tomalak Jul 02 '20 at 07:30
  • Apart from that, the method to do the same thing on MySQL is different. Throw out the [mysql] tag if you're actually using SQL Server. – Tomalak Jul 02 '20 at 07:31

1 Answers1

-1

Figured out what to do.

Don't want to delete the post as it may get me banned from here.

Basically, I followed this - https://www.w3schools.com/asp/ado_display.asp but set latest equal to the sql output in the for-each loop.

  • 1
    If you refer to external sources, always also include the code you used here. When in the future someone has the same problem, ends up here, and the link is dead, they won't know what you're talking about. So it's better if you show code and keep the link strictly for reference. – Tomalak Jul 02 '20 at 07:27