datatable.compute not working

elainec351

Member
Joined
Feb 28, 2008
Messages
12
Programming Experience
Beginner
Help?

Can anyone tell me why this is not working? I took it straight from the MSDN help files, with a little modification to reflect my dataset and table names.

My dataset and refund table are being created by the ReadXML function(?) and the data is being used in a datagrid, but I want to put the sum of all the records in the datagrid that have the confirm check set to true into a Total Amount text box underneath the datagrid.

This sub is being called many times as the ReadXML is adding records to the dataset so my Try Catch doesn't really do anything if there is an error, but the problem is there is an exception thrown everytime this is called whether the dataset has data in it or not and of course the actual sum is not going into the text box.

Thanks to anyone that can help me with this annoying issue.

VB.NET:
Private Sub ComputeTotalAmount()
        Dim dsDataset As DataSet = New DataSet("dsXMLData")
        Try
            If dsDataset.Tables("refund").Rows.Count > 0 Then
                tbTotalAmount.Text = dsDataset.Tables("refund").Compute("Count(IssuingCountry)", "Confirm = 0").ToString
            Else
                tbTotalAmount.Text = Format(0, "0.00")
            End If
        Catch ex As Exception

        End Try
    End Sub
 
Back
Top