• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: How to create null SQL parameter for a UniqueIdentifier?

Resolved: How to create null SQL parameter for a UniqueIdentifier?

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

While doing
gives me no error, this instead
gives me an error saying the value cannot be null.
Any idea?
Thank you in advance

Answer:

What is happening is that Iif will always evaluate (run) both parts. So the last part will throw an exception since Id_Padre is nothing. From documentation (https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/iif-function):

IIf always evaluates both truepart and falsepart, even though it returns only one of them. Because of this, you should watch for undesirable side effects. For example, if evaluating falsepart results in a division by zero error, an error occurs even if expr is True.


I recommend using If instead to avoid this (https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/operators/if-operator) so:

If you have better answer, please add a comment about this, thank you!

vb.net
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Unable to run Docker .NET 6 console image

02/04/2023

Resolved: Input Focus between two React Components

02/04/2023

Resolved: linq2db throws exception when filtering by nested collection

02/04/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.