Save method on Entity returns False

Posts   
 
    
Dazza
User
Posts: 2
Joined: 30-Mar-2005
# Posted on: 31-Mar-2005 07:43:10   

Hi,

I'm fairly new to LLBLGen development and am having a problem with the "Save" method on the "Two Class Scenario" generated code. I have hunted through the forum, but couldn't find anything relevant to my problem. The code is fairly simple:


Dim udtRefTypeData As New EntityClasses.ReferenceDataTypesEntity

udtRefTypeData.IsNew = True

udtRefTypeData.ReferenceDataTypeCode = txtRefDataTypeCode.Text

udtRefTypeData.Description = txtRefDataDescription.Text

Dim bolSaveResult As Boolean = udtRefTypeData.Save()

Here's the database structure:

CREATE TABLE [dbo].[tblReferenceDataTypes] ( [ReferenceDataTypeCode] [nvarchar] (50) NOT NULL , [Description] [text] NULL ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] GO

ALTER TABLE [dbo].[tblReferenceDataTypes] ADD CONSTRAINT [PK_ReferenceDataTypes] PRIMARY KEY CLUSTERED ( [ReferenceDataTypeCode] ) WITH FILLFACTOR = 90 ON [PRIMARY] GO

The problem I am having is that the "Save" method is returning False (no exception is thrown). However, the record ** does** actually get saved to the database. I believe it could be a problem when the Entity object attempts to re-fetch the data after the save.

This is puzzling me as it seems to behave differently depending on the SQL Server environment. We have a Development SQL Server, on which it operates as expected, with the Save method returning True. However, when I try the same code on the Test SQL Server, the Save method returns False.

The DBA has used a script to create the database on the SQL Test Server. The same script has been run on my local machine's SQL Server. However, When running the above code against my local SQL Server database, all works fine.

Is there any global SQL Server properties, config settings or anything else that could be causing this weirdness?

Also, is there any way of further interrogating what caused the Save method to return False?

Darryl.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 31-Mar-2005 10:21:34   

Ah, I think the cause is in the SqlServer connection parameters, defined in enterprise manager. If you open enterprise manager and right click on the server which returns false with your code, you should select properties.

Then go to the connections tab and UNcheck 'No count'.

if this isn't checked, please let me know

The cause is that rowcounting is switched off globally, which means that the number of rows affected by queries is always 0, which makes the code think something failed and returns false. You'll also see that if you try to save recursively, it will throw a concurrency exception.

Frans Bouma | Lead developer LLBLGen Pro
Dazza
User
Posts: 2
Joined: 30-Mar-2005
# Posted on: 01-Apr-2005 06:21:15   

That fixed the problem! smile

Thanks for your prompt reply.

Regards, Darryl.