Has something changed for setting fields to null?

Posts   
 
    
JimFoye avatar
JimFoye
User
Posts: 656
Joined: 22-Jun-2004
# Posted on: 29-Sep-2005 19:06:10   

I've been using SetNewFieldValue to set fields on existing entities to null, per the docs. Today I went back to make a change to some code from last year, this was the first project I used LLBLGen Pro on, and found this:

            if (this.FirstName.Text.Length > 0)
                dalPerson.FirstName = this.FirstName.Text;
            else
                dalPerson.FirstName = null;

Interestingly, this code appears to work if I don't put a first name in the form. I see NULL in the database. This code uses self-servicing against SQL Server, and I just updated it to 1.0.2004.2 (Aug 5).

Did something change confused

Jim

pilotboba
User
Posts: 434
Joined: 05-Aug-2005
# Posted on: 29-Sep-2005 23:19:21   

JimFoye wrote:

I've been using SetNewFieldValue to set fields on existing entities to null, per the docs. Today I went back to make a change to some code from last year, this was the first project I used LLBLGen Pro on, and found this:

            if (this.FirstName.Text.Length > 0)
                dalPerson.FirstName = this.FirstName.Text;
            else
                dalPerson.FirstName = null;

Interestingly, this code appears to work if I don't put a first name in the form. I see NULL in the database. This code uses self-servicing against SQL Server, and I just updated it to 1.0.2004.2 (Aug 5).

Did something change confused

Jim

String is a reference type, so it probably has always been supported. It is probably for values types that you need to use SetNewFieldValue.

BOb

JimFoye avatar
JimFoye
User
Posts: 656
Joined: 22-Jun-2004
# Posted on: 30-Sep-2005 01:28:19   

Ah, think you're right. Thanks.