Join 132,646 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,122 people online right now. Registration is fast and FREE... Join Now!
I have an INSERT statement to create a new record and I would like to return the ID value from the newly created record. I believe I have to use the Scope_Identity() function but not sure how to actually write it out to my page after it's returned.
Ok so I'm sure I'm getting close but this is just not working:
CODE
PSR_ID_SQL="SELECT cast(SCOPE_IDENTITY() as bigint) AS tbl_PSRs" set RsPSR_ID = oConn.execute(PSR_ID_SQL) Response.write "The ID: " &RsPSR_ID(0) response.end
The recordset appears to be empty, as nothing is displayed after the "The ID:" bit.
I'm getting around this right now by requerying the table for the highest value in the field immediately after insert, but I know this could lead to severe problems if someone creates a record between the insert and the query. I really want to use Scope_Identity().
What am I missing?????????????????????????????????????????????????????