SELECT Scope_Identity() AS ID not working?
Hi all,
I've had this code in an application for a while and it stopped working when my server was migrated to CF8 from CF7. It's writing to a SQL Server 2005 DB.
<cfquery name="insertGame"
datasource="#application.datasource#"
username="#application.datasource_username#"
password="#application.datasource_password#">
INSERT INTO cdw_games(gameName)
VALUES ('#FORM.gameName#')
SELECT Scope_Identity() AS ID
</cfquery>
<cfloop index = "loopCount" from="1" to="10">
<cfquery name="insertTeams"
datasource="#application.datasource#"
username="#application.datasource_username#"
password="#application.datasource_password#">
INSERT INTO cdw_teams(teamName, gameID)
VALUES ('Team#loopCount#','#insertGame.ID#')
</cfquery>
I'm getting a 500 error saying that "Element ID is undefined in insertGame." Any idea why this is happening?
I also tried adding "result=newGameID" to the cfquery tag, then referenced newGameID.IDENTITYCOL and got the same error, element IDENTITYCOL is undefined in newGameID.
This is hosted on goDaddy, so I'm assuming it's something they did because it's been working for a number of years now.
Any ideas?
Thanks,
Keith
