473,471 Members | 4,687 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

DataTable Compute null values

gchq
96 New Member
Hi there

I am attempting to compute some values from a DataTable. It works fine as long as there is a value to retrieve, otherwise it blows out!

This will work as there are valid dates:-

Expand|Select|Wrap|Line Numbers
  1. Actuals_09.InnerText = Format(nTable.Compute("Sum(Amount)", "Item_Date >= " & "'" & vMonth09 & "'" & " AND Item_Date < " & "'" & vMonth10 & "'"), "###,##0.00")
But this will not:-

Expand|Select|Wrap|Line Numbers
  1. Actuals_02.InnerText = Format(nTable.Compute("Sum(Amount)", "Item_Date >= " & "'" & vMonth02 & "'" & " AND Item_Date < " & "'" & vMonth03 & "'"), "###,##0.00")
Is there a DataTable equiv. of IsNull ??? Or is there another way round this?

Thanks in advance
Mar 22 '07 #1
2 18806
gchq
96 New Member
OK - found a way round it!

Expand|Select|Wrap|Line Numbers
  1. Dim vActual01 As Object = nTable.Compute("Sum(Amount)", "Item_Date >= " & "'" & vMonth01 & "'" & " AND Item_Date < " & "'" & vMonth02 & "'")
  2.         If Not vActual01.Equals(DBNull.Value) Then
  3.             Actuals_01.InnerText = Convert.ToDouble(Format(vActual01, "###,##0.00"))
  4.         Else
  5.             Actuals_01.InnerText = "0.00"
  6.         End If
Mar 22 '07 #2
kenobewan
4,871 Recognized Expert Specialist
Well done! Thanks for sharing the solution. You could also use a try catch block to catch any errors.
Mar 23 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Michael Howes | last post by:
I have a single DataTable in a DataSet. It has 4 columns and i'd like to get a handful of counts of unique items in 3 of the 4 columns. Can a DataTables Select or Compute methods to COUNT DISTINCT?...
3
by: chrisben | last post by:
Hi, I would like to query a datatable in C#. The query is like select sum(quantity) from table where company="IBM" And I would get this number and display it in my GUI. Is there a way to...
2
by: Ricardo Luceac | last post by:
HI all.. I have a huge table that I want to display in a datagrid, the problem is that if I make a dataset, the entire table must go to the dataset to the data begin to display, and it takes...
0
by: Chris Ericoli | last post by:
Hi, I am working with an 'in session' ado dataset with an asp.net application. My dataset is comprised of two tables, one of which maintains a few calculated datacolumns. For some reason these...
1
by: Ersin Gençtürk | last post by:
I have 2 typed data tables inherited from the same dataset schema One called : table A with an identity column x column x is constrained to be unique. Other one is : table B with an identity...
3
by: DaveF | last post by:
I have a dataset with an unknown amount of fields. The user can choose a nuber of numeric fields in that datatable. I am making a chart out of those fields. I need to know the minimum and maximun...
2
by: Roy | last post by:
Hi all, I do have a datatable that looks like: id Number Description 1 1 Desc1 2 1 Desc2 3 2 Desc3 I need this datatable looks like (with 4 rows...
2
by: Marcel Hug | last post by:
Hi NG! With a Inner-Join SQL I get my datas in a DataSet. In the table are the column Entry and Version. Like this: Entry Version 1 1 1 2 1 ...
0
by: Maart_newbie | last post by:
Hi all, I've got a question about returning the value of a pk-column to a DataTable after inserting a row (via a data-adapter) using MySql5. Here is the SQL and code concerned: ...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.