IDENTITY, Access, and multiple SQL statements

A

Andrew Poulos

From http://databases.aspfaq.com I got this bit of ASP code for getting
the identity value for a row inserted into an MS Access database:

<%
fakeValue = 5
set conn = CreateObject("ADODB.Connection")
conn.open "<conn string>"
sql = "INSERT someTable(IntColumn) VALUES(" & fakeValue & ")" & _
VBCrLf & " SELECT @@IDENTITY"
set rs = conn.execute(sql)
response.write "New ID was " & rs(0)
rs.close: set rs = nothing
conn.close: set conn = nothing
%>


I write ASP using JavaScript and converting the sql string to

sql = "INSERT someTable(IntColumn) VALUES(" + fakeValue + ")";
sql += "\r\n SELECT @@IDENTITY";

gives me an error that the SQL statement doesn't end in a semi colon. If
I add a semicolon to the end of the first SQL statement I get an error
that there are additional characters after the SQL statement.

Is there a way to get this to work or is aspfaq.com mistaken that you
can run multiple SQL statements on an MS Access database?

Andrew Poulos
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,069
Latest member
SimplyleanKetoReviews

Latest Threads

Top