Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Iif(isdbnull correct syntax?
Message
From
31/12/2002 18:14:21
 
 
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00736677
Message ID:
00737094
Views:
23
Roland,

>>Not sure if iif function supports that type of coding.<<

I don't know either ... IIf is only in VB, and I'm coding in C#. Looks like you'll have to code it the long way if you can't figure out the problem ...

~~Bonnie



>Hi Bonnie,
>
>Not sure if iif function supports that type of coding. Its seems to be getting confused and will not let the result = decision of the iif( function. Like its trying to return the true/false instead of the values.
>
>This code works, but too much coding.
>
>
>     Dim strAPN As String
>     If myDataRow("APN") Is DBNull.Value Then
>         strAPN = "Null"
>     Else
>         strAPN = myDataRow("APN")
>     End If
>     MessageBox.Show(strAPN)
>
>
>This does not work - Error Cast from type 'DBNull' to type 'String' is not valid.
>     MessageBox.Show(IIf(myDataRow("APN") Is DBNull.Value, "", Trim(myDataRow("APN"))))
>
>
>
>Next year Mircosoft may have all the bugs fixed, NOT.
>
>Have a Happy New Year!!!!!!!!!!!!
>
>Thanks for all your help and all the other professionals on these forum.
>
>Sincerely,
>Roland
>
>==========================================================================
>
>>Dunno Roland ... it sure looks like it should work (but I haven't used the IsDBNull() function). How about trying this intead:
>>
>>
>>
>>IIf(MyDataRow("APN") = DBNull.Value, "", Trim(MyDataRow("APN"))
>>
>>
>>~~Bonnie
>>
>>>Hi,
>>>
>>>I encountered the following error message with the code below the error message.
>>>
>>>An unhandled exception of type 'System.InvalidCastException' occurred in microsoft.visualbasic.dll
>>>Additional information: Cast from type 'DBNull' to type 'String' is not valid.
>>>
>>>MyEmailBody = myDataRow("AccountId") & " " & _
>>>myDataRow("OrderNumber") & " " & _
>>>IIf(IsDBNull(myDataRow("APN")), "", Trim(myDataRow("APN"))) & " " & _
>>>IIf(IsDBNull(myDataRow("StreetNumber")), "", Trim(myDataRow("StreetNumber")))
>>>
>>>What is the proper code to cancanate the string?
>>>
>>>Any help would be greatly appreciated.
>>>
>>>
>>>Thanks
>>>Roland
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Reply
Map
View

Click here to load this message in the networking platform