.NET - Null Condition Not Working

Trying to set a simple condition to check if a column returns NULL in a query.
qDetails.intClass == null

But this always returns false. The column is of type INTEGER in a MSSQL DB.
Haven’t noticed this before. So not sure if its a new bug or an existing one.

If I try to put in != null that always returns true, even when the value is actually null.
I also tried changing to condition to something like !qDetails.intClass & qDetails.intClass <=0, but both returned error that cannot convert Null to boolean/double.

Please help.

Hi Sid
I’m not sure if you have the same problem, but I have had precedents when Wappler converted null to a string value 'null'. Try the check != 'null'. If this works, then the problem is the same.

I thought that too. But when checked, value returned in response JSON is actually null. And not the string.

I have to check if we do some conversions for null values coming from a database. In ASP.NET the null values coming from a database are a special type https://docs.microsoft.com/en-us/dotnet/api/system.dbnull that is not the same as the standard null.

Oh yes. I remember reading about this when configuring an entity framework thing in a Visual Studio project.
Would be great to have a solution. But its interesting that I have never encountered this before. :exploding_head:

I have updated the ASP.NET database component with an improved null check, not sure if it will fix your issue but it is worth to try.

DMXzone.ServerConnect.DatabaseConnector.zip (27.1 KB)

Thanks for the update @patrick . Finally tested it today.
The DLL is throwing an error now. I can no longer login as well.
Error files: errors.zip (4.2 KB)

The errors are a bit strange, they come from the Database and not from .NET. The login error is throwing Incorrect syntax near 'OFFSET'. and the other is Incorrect syntax near '0'..

I did notice that. But its not from my query.
Offset one is from security login.
Something in the dll is messing the query, because restoring current files works just fine.

Seems it is related to an other update I did in the component for the paging. Here a new update.

DMXzone.ServerConnect.DatabaseConnector.zip (27.2 KB)

Thanks for the update. The condition for checking null is still failing. Null values seem to be treated as empty string in condition. Output of query shows null correctly.
So, query1.intClass == null fails, but query1.intClass == '' returns true.

I can’t see anything wrong with the database connector, it seems to generate the null values correctly.

I’ve now made some changes to the expression parser and how it handles comparing null values, please give the update a try.

DMXzone.ServerConnect.zip (52.0 KB)

With this the null condition now works. :slight_smile:

This has been fixed in Wappler 4.0.5

This topic was automatically closed after 31 hours. New replies are no longer allowed.