reapesuk
asked on
How to test for null values using the dreamweaver datasets
Hi,
I am using a dreamweaver dataset that has a query for totalling values in a database in a VB ASP.NET page. The code to display my total is (as placed by DWMX when you drag the field) :
<%# QryBasketTotal.FieldValue( "TOTALAMOU NT", Container) %>
This displays the totals fine, but not formatted to 2 decimal places so I tried the following:
<%# formatCurrency(QryBasketTo tal.FieldV alue("TOTA LAMOUNT", Container),2) %>
Which also works UNTIL the value of "TOTALAMOUNT" is empty or null, then it falls over in a big heap.
So, my question is, how can you test for a null value in ASP.NET on a dataset?
I have tried making my own functions to do a simple if <blah> is NULL then... but it would appear NULL is not supported, so I tried dbNull.Value (as found on the web):
function DisplayTotal() as String
Dim Container
if QryBasketItems.FieldValue( "TOTALAMOU NT", Container) is dbNull.Value then
DisplayTotal="0.00"
Else
DisplayTotal =formatCurrency(QryBasketT otal.Field Value("TOT ALAMOUNT", Container),2)
End If
End function
But THIS fails with "System.FormatException: Input string was not in a correct format."
PLEASE PLEASE PLEASE, does anyone know what I am doing wrong?
Thanks
Jimbo
I am using a dreamweaver dataset that has a query for totalling values in a database in a VB ASP.NET page. The code to display my total is (as placed by DWMX when you drag the field) :
<%# QryBasketTotal.FieldValue(
This displays the totals fine, but not formatted to 2 decimal places so I tried the following:
<%# formatCurrency(QryBasketTo
Which also works UNTIL the value of "TOTALAMOUNT" is empty or null, then it falls over in a big heap.
So, my question is, how can you test for a null value in ASP.NET on a dataset?
I have tried making my own functions to do a simple if <blah> is NULL then... but it would appear NULL is not supported, so I tried dbNull.Value (as found on the web):
function DisplayTotal() as String
Dim Container
if QryBasketItems.FieldValue(
DisplayTotal="0.00"
Else
DisplayTotal =formatCurrency(QryBasketT
End If
End function
But THIS fails with "System.FormatException: Input string was not in a correct format."
PLEASE PLEASE PLEASE, does anyone know what I am doing wrong?
Thanks
Jimbo
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have "solved" it another way by converting the value (or not as the case may be) to a string and then testing for an empty string:
MyValue=QryBasketTotal.Fie
Probably not the best solution but it works.