I'm having a real hard time with displaying the proper data in Project Summary. First off, I am using an Access database to bring in the data. Total hours are being calculated correctly. Rates are as well. I tested using a messagebox to make sure the rates are being grabbed from the database correctly. However, now to get the total cost to multiply the individual rates by the individual hours is where I'm having the problem.
So to sum it all up, ALL I want to be able to do is multiply data from one table with data from another table. TWO separate select string statements. What am I doing wrong?!
Below I pasted the code I have so far and the directions in the assignment specs for this particular button. I highlighted the problem areas. If any one has any suggestions, they'd be greatly appreciated!

Thanks in advance...

[B]Project Summary[/B](button) – This button should display the total dollars and total hours expended on the currently selected project.   If the user clicks this button before a current project has been successfully selected, display an error message box and exit the sub. 
In order to produce the total hours and dollars, your logic will have to search the database tables billing and employee to look for charges to the current project the user has entered.
To compute dollars for that charge use, pay rate * hours charged.

My Code:

Private Sub btnSummary_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnSummary.Click

        Dim targetid As String
        Dim selectstring As String
        Dim selectstring2 As String
        Dim dummy As Integer
        Dim amount As String = ""
        Dim totalHours As Double = 0
        Dim totalCost As Double = 0
        Dim Hours As Double = 0
        Dim Rate As Double = 0

        If Not Integer.TryParse(txtPID.Text.Trim, dummy)
            MessageBox.Show("member id must be integer")
            Exit Sub
        End If
        targetid = txtPID.Text.Trim

        'select string statements

        selectstring = "select * from billing where
bill_projid ='" & _
                        targetid & "'"
        selectstring2 = "select * from employee,billing
where employee.emp_id = billing.bill_empid" & _
                        " and billing.bill_projid ='" &
targetid & "'"


        projectadapter = New
OleDb.OleDbDataAdapter(selectstring, connectionstring)
        employeeadapter = New
OleDb.OleDbDataAdapter(selectstring2, connectionstring)

        emptable = New DataTable

        projtable = New DataTable

        If projtable.Rows.Count = 0 Then
            lblDisplay.Text = "You have not yet loaded a
            Exit Sub
        End If

        If emptable.Rows.Count = 0 Then
            lblDisplay.Text = "You have not yet loaded a
            Exit Sub
        End If

        'for projtable
        For ndx = 0 To projtable.Rows.Count - 1

            totalHours +=
            Hours =
            'MessageBox.Show(CStr(Hours))<<-- each hour shows up correctly

        'for emptable
        For indx = 0 To emptable.Rows.Count - 1

            Rate =
            'MessageBox.Show(CStr(Rate))<<-- each rate shows
up correctly

        total += Rate * Hours <<-- Always comes up as 80 (40
* 2)

        totalCost = total

        lblDisplay.Text = "Total Hours to date: " &
totalHours.ToString & Environment.NewLine _
                        & "Total Cost to date: $" &
totalCost.ToString & Environment.NewLine

End Sub
8 Years
Discussion Span
Last Post by danielle23

Found out what the problem was. I was actually over-thinking A LOT. Turns out, it was just a simple database load from the class in the application that I needed to tweak. The Summary button didn't even need any database code.
Thanks though for responding!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.