Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to test for null values using the dreamweaver datasets

Posted on 2004-10-01
2
Medium Priority
?
538 Views
Last Modified: 2012-05-05
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("TOTALAMOUNT", Container) %>

This displays the totals fine, but not formatted to 2 decimal places so I tried the following:

<%# formatCurrency(QryBasketTotal.FieldValue("TOTALAMOUNT", 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("TOTALAMOUNT", Container) is dbNull.Value  then
            DisplayTotal="0.00"
      Else
            DisplayTotal =formatCurrency(QryBasketTotal.FieldValue("TOTALAMOUNT", 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
0
Comment
Question by:reapesuk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 19

Accepted Solution

by:
webwoman earned 380 total points
ID: 12203053
There's an isNull command in classic ASP that returns true/false. I suspect it still exists.
if isNull(QryBasketItems.FieldValue("TOTALAMOUNT", Container))  then

You can see what that does. At least you're only debugging one thing, so it's easy to know if it's working or not. ;-)
0
 

Author Comment

by:reapesuk
ID: 12203206
Thanks Webwoman but this function doesn't exist in ASP.NET VB.

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.FieldValue("TOTALAMOUNT", Container).ToString

Probably not the best solution but it works.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those who don't know, Adobe Dreamweaver is a popular commercial web editor that enables you to design, build and manage complex websites. The editor is a WYSIWYG (What You See Is What You Get) web editor, which means that you can create your web…
I still run into .cgi files every now and then. In some instances, I actually prefer the simplicity of a .cgi script to other options. Since I use DreamWeaver extensively, what I needed was a way to open .cgi scripts in Dreamweaver. And I wanted to …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question