Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Tuesday, July 1, 2025 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Web Forums - SalesLogix Web Platform & Application Architect
Forum to discuss the use of the SalesLogix Web Platform, Client and Customer Portals, and the Application Architect (For version 7.2 and higher only). View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Web Platform & Application Architect | New ThreadView:  Search:  
 Author  Thread: Unexpected Row Count 0 : Expected 1
Howard Towner
Posts: 6
 
Unexpected Row Count 0 : Expected 1Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 07 Dec 09 3:45 PM
Hi

Has anyone any ideas on this error.

When I save an existing contact from the contact details screen I get the error:

StaleStateException Unexpected Row Count 0 : Expected 1

This is occurring when I make no changes to the form. If I make a change to the phone fields I don't get the error.

After dismissing the exception, when I click save it saves correctly. This seems to be localised to contacts that already existed, on the database.

Does anyone have any ideas as to what the problem is? Or alternatively how I can interrogate the exception to find which row it is complaining about?

Here is the code the exception is produced in, after Session.Flush();

Thanks

ISession session = SessionFactoryHolder.HolderInstance.CreateSession();
try
{
if (PersistentState == PersistentState.Modified)
{
_OnBeforeUpdate(this, session);
}
#region 1:1 extension update handlers
if (ContactExtra.PersistentState == PersistentState.Modified)
{
Sage.SalesLogix.Entities.ContactExtra._OnBeforeUpdate(ContactExtra, session);
}
if (ContactPermission.PersistentState == PersistentState.Modified)
{
Sage.SalesLogix.Entities.ContactPermission._OnBeforeUpdate(ContactPermission, session);
}
#endregion 1:1 extension update handlers

if ((PersistentState & PersistentState.New) == PersistentState.New)
{
session.Save(this);
}
else
{
session.Update(this);
}
_LastPersistedOwner = _Owner; session.Flush();
PersistentState = PersistentState.Unmodified;
OnPersisted();
ClearChanges();
}
finally
{
SessionFactoryHolder.HolderInstance.ReleaseSession(session);
}
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Unexpected Row Count 0 : Expected 1Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 07 Dec 09 4:48 PM
I recall running into similar issues in the past.

Make sure that:
- Your Contacts have valid addresses (AddressID and ShippingID, and that the addressses do exist)
- Your Contacts have valid Owners and Account Managers (I have seen cases where the UserID no longer exists, or the Owner (a deleted team) and that causes problems with the data)

That may also be why the problem occurs with existing data and not with newly created records.
Maybe consider running the the Integrity checker as well.

If all fails to fix, go ahead and run the SLX Profiler. Look for related queries that return 0 rows and try and determine if they should've at least returned 1 row...
[Reply][Quote]
Howard Towner
Posts: 6
 
Re: Unexpected Row Count 0 : Expected 1Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 08 Dec 09 6:32 AM
Thanks

The problem has now been solved, the problem was caused by a trigger on the contact_extra table that has now been disabled.
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Unexpected Row Count 0 : Expected 1Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 08 Dec 09 9:19 AM
Well, you are have way there, you identified the problem.

Here is the solution, in order to keep the trigger working:

Make sure to set the NOCOUNT option to on at the beggining of the trigger, and turning it off right before the end of the trigger:
TRIGGER
SET NOCOUNT ON
...
HERE GOES MY TRIGGER CODE
...
SET NOCOUNT OFF
END TRIGGER
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2025 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 7/1/2025 1:10:50 PM