![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Null parameter problem I have a function that takes two arguments Public Function CheckThing(ByVal b As Boolean, ByVal s as String) As String : The function is called from inside a FormView control like this: <%#CheckThing(Eval("flag"),Eval("myfield"))%> Everything works fine except when myfield has a null value: I'll then get an error saying something like ".can not convert DBNull to string.." What's the best way to handle situation like this? Thanks. I'm using VS2005, and SQL Server database. |
My System Specs![]() |
| | #2 (permalink) |
| Vista Business x64 | Re: Null parameter problem There area number of ways. First, if you are okay with deciding there should be no nulls in this field from the db, modify the sproc that returns the data to replace myfield with ISNULL(myfield,'') in the T-SQL select statement. There are ways to handle it in the app code as well. I have been using C#.NET since 2003, so I will have to pull up VS and figure out the equivalent VB.NET syntax. I'll post back later with that. |
My System Specs![]() |
| | #3 (permalink) |
| Vista Business x64 | Re: Null parameter problem Replace myfield with: IIf(Eval("myfield") Is System.DBNull.Value, "", Eval("myfield")) You can also change the parameter type to allow a DBNull to come across and handle it in the CheckThing function. |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Script parameter problem | PowerShell | |||
| Re: "Error: 'null' is null or not an object" when trying to view video | Vista performance & maintenance | |||
| Gotcha: $null to [string] IS NOT $null | PowerShell | |||
| Problem with WMI in WinPE - null: Invalid Syntax Error | Vista installation & setup | |||
| How to best control parameter attributes and parameter parsing in your own scripts? | PowerShell | |||