LLBLGenProDataSource2 & empty form field

Posts   
 
    
Marco avatar
Marco
User
Posts: 13
Joined: 27-Jul-2007
# Posted on: 18-Mar-2008 17:53:50   

Hi,

I am getting some weird behaviour. I have a DetailsView that has a LLBLGenProDataSource2 as it's data source. LivePersistence is set to false, AllFieldsKeepEmptyStringAsValue is set to true. When editing a field through the DetailsView, the changes are saved properly, so no problems there. The problem occurs when I try to remove the text from a certain field. This is what happens: I remove all text in the bound textbox and press Save (which is allowed) and then when I look in the record in the database, the field still has it's old value. When I put a breakpoint in the PerformWork method and look at the entity by using e.Uow.GetEntityElementsToUpdate(), I also see that the field still has the old value, instead of "". confused

The data type of the field in the database is Text, Allow Nulls is set to false and the default value is set to Space(0).

I am using LLBLGen Pro 2.5 (Adapter, C#), SQL Server 2000 and Visual Studio 2005.

Hope I'm making myself clear. If not: please let me know. wink

Kind regards,

Marco Kramer

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 19-Mar-2008 08:44:50   

Which LLBLGen Pro runtime library version are you using?

Also would you please attach a simple repro solution based on Northwind?

Thanks.

Marco avatar
Marco
User
Posts: 13
Joined: 27-Jul-2007
# Posted on: 19-Mar-2008 14:08:57   

Not sure what runtime library version I am using, but I am using version LLBLGen Pro 2.5 Final, released on September 24th 2007.

I have attachted my Northwind solution that shows the problem (I removed SD.LLBLGen.Pro.DQE.SqlServer.NET20.dll and SD.LLBLGen.Pro.ORMSupportClasses.NET20.DLL from the Bin folder to be able to upload it).

To reproduce the problem, you should add a field to the Employees table:

Column Name = Notes2 Data Type = text Allow Nulls = False Default Value = space(0)

Now run the solution, click Edit and add some text to Notes. Press Update and you see that the text is saved. Now click Edit again and remove all text from Notes and press Update. As you can (hopefully) see the text is still there.

The problem seems to be related to the "Allow Nulls = False". If I edit the Notes field, it works fine.

Attachments
Filename File size Added on Approval
Northwind.zip 18,669 19-Mar-2008 14:10.51 Approved
Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 19-Mar-2008 16:53:52   

Looking into it.

(Edit) I think that the detailsView databinding is returning a value of NULL instead of en emptyString, and this might catched in the BuiltInValidation logic as the field doesn't allow NULL.

(Edit) Looks like a bug, I'll escilate the issue and we will get back to you soon.

(Edit) Please use the following line in your appsettings configuration: <add key="buildInValidationBypassMode" value="1"/>

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39903
Joined: 17-Aug-2003
# Posted on: 19-Mar-2008 18:16:34   

Sounds like a bug indeed. Will look into it. There's empty string == null code in place so it's likely that it makes the wrong decision at some point. Thanks for the repro case, that will help track this down easier simple_smile

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39903
Joined: 17-Aug-2003
# Posted on: 20-Mar-2008 10:55:50   

The error is in your code, I'm afraid.

The grid has for every field a property (click on 'Edit fields' in the smarttag of the grid): ConvertEmptyStringToNull. THis is by default set to true. This means that an empty value is send to the datasourcecontrol as null, not as empty string. So the datasourcecontrol receives a null, which means it can't accept it as the field isn't nullable. If you set the property ConvertEmptyStringToNull to false for a textfield which should accept "", an empty textbox will send a "" to the datasourcecontrol, which is then accepted as a value. simple_smile

Frans Bouma | Lead developer LLBLGen Pro
Marco avatar
Marco
User
Posts: 13
Joined: 27-Jul-2007
# Posted on: 20-Mar-2008 11:41:58   

Oh man... I feel silly. flushed I didn't even know that that property existed... Just tested it and yes, this fixed it.

Anyway, thank you both for solving this for me and sorry for taking your time!

Did I already say the support rocks? wink

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39903
Joined: 17-Aug-2003
# Posted on: 20-Mar-2008 13:16:08   

Marco wrote:

Oh man... I feel silly. flushed I didn't even know that that property existed... Just tested it and yes, this fixed it.

Anyway, thank you both for solving this for me and sorry for taking your time!

Did I already say the support rocks? wink

simple_smile Glad it's solved simple_smile

Frans Bouma | Lead developer LLBLGen Pro