Link to home
Start Free TrialLog in
Avatar of yo_bee
yo_beeFlag for United States of America

asked on

VB.net Tableadapter query not showing desired results

I have a simple VB datagridview form that is used to update a table in my MSSQL DB.
Form looks like this:
User generated image
I need to run the query and get sum total of all the values.
Here is my TableAdapter  query.
 Private Sub SearchBTN_Click(sender As Object, e As EventArgs) Handles SearchBTN.Click
        Me.CV_Allocation_TblTableAdapter.FillMatterID(CVDataSet.CV_Allocation_Tbl, Nothing)
        StatusLabel1.Text = "Ready"
        Try

            If CheckBox1.Checked = False Then
                Me.CV_Allocation_TblTableAdapter.FillMatterID(CVDataSet.CV_Allocation_Tbl, TextBox1.Text)
            Else
                Me.CV_Allocation_TblTableAdapter.FillExactMatterid(CVDataSet.CV_Allocation_Tbl, TextBox1.Text)
                MsgBox(Me.DataTable1TableAdapter.FillSUM(CVDataSet.DataTable1, TextBox1.Text))
            End If
        Catch ex As Exception

        End Try

Open in new window


 User generated image
SELECT        SUM([Partner Origination] + [Responsible Partner] + [Case Manager]) AS Total
FROM            cv_allocation_tbl
WHERE        (MatterID = @matterid)
GROUP BY MatterID

Open in new window


When I run my form I get a value of 1 for Msgbox when I expect 100.

User generated image
SOLUTION
Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMP
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of yo_bee

ASKER

No particular reason other then I do not know how to accomplish the suming for this.

This is the reason for me posting for suggestion.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of yo_bee

ASKER

I ended up coming up with something slightly different than my original code. The reason I gave Kyle points is his recommendation of keeping within the same tableadapter.  I did not know know to leverage Louis recommendation of compute method, but it seemed like another viable option from what I saw on the internet.