Hi everyone.
First the required info:
-- Version 1.0.2005.1 Final (july 6th, 2006)
-- Runtime file (SD.LLBLGen.Pro.ORMSupportClasses.NET10.dll) version 1.20051.7.307
-- Self-servicing - general scenario
So this is a codebase that has been used successfully for over a year on installations with either sql server 2000 or sql server 2005 as the DBMS.
Today I get this email from my account guy:
The web server is regular 32 bit with a 64 bit db server. When adding a new user I receive the error below. It seems as though anytime there is a llblgen insert followed by a command that gets the last foreign key this issue arises. Llblgen pulls a blank userid which then throws the foreign key error….however the user does get inserted and a key is correctly generated. One item of note is this was a fresh install so any sql settings that are needed for this to work might not be set.
An exception was caught during the execution of an action query: The INSERT statement conflicted with the FOREIGN KEY constraint "FK_tUserApplication_tUsers". The conflict occurred in database "TotalRecord", table "dbo.tUsers", column 'UserID'.
The statement has been terminated.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: SD.LLBLGen.Pro.ORMSupportClasses.ORMQueryExecutionException: An exception was caught during the execution of an action query: The INSERT statement conflicted with the FOREIGN KEY constraint "FK_tUserApplication_tUsers". The conflict occurred in database "TotalRecord", table "dbo.tUsers", column 'UserID'.
The statement has been terminated.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception.
The code that is roughly around where this is happening looks like this:
'''' some other property value setting happens here
_User.IsNew = True
_User.Save()
Dim _applications As New ApplicationCollection()
_applications.GetMulti(Nothing)
If _applications.Count > 0 Then
Dim _userApplication As New UserApplicationEntity()
_userApplication.UserID = _User.UserID
_userApplication.ApplicationID = _applications.Item(0).ApplicationID
_userApplication.IsNew = True
_userApplication.Save()
End If
We don't have a 64-bit environment locally, so debugging this one has been kind of tough. Apparently the new entry goes into the User table fine.. gets an autogenerated ID like it's supposed to, but that ID doesn't get put back into the entity for use later.
This is happening anywhere in the code that an insert is happening and then the newly-created ID is referenced for something else; it's returning null.
Any thoughts as to why this would be different in a 64-bit SQL 2005 environment as opposed to 32-bit?
As always help is most appreciated.
Matt