View Single Post
  #1 (permalink)  
Old November 15th, 2013, 11:19 AM
D-Bar D-Bar is offline
Registered User
Points: 15, Level: 1
Points: 15, Level: 1 Points: 15, Level: 1 Points: 15, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Sep 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Trying to get total hours

Hello all. Thanks for reading my post. I developed a "time clock" to keep track of hours worked. I have the hours worked for the day. I need to get the total hours for each employee. I am hitting a wall. I have two calendar controls to select a date range. I am able to display the info. from the database into a gridview which includes daily hours and the employee's name. How can I get the total hours for each employee for the selected date range? They don't have to go into the gridview. I could display names and total hours using labels placed below the gridview. Here is the code I am using to get the data into the gridview.

Protected Sub Calendar332_SelectionChanged(sender As Object, e As EventArgs)
'declare SQL statement that will query the database
Dim sqlstring As String = SELECT firstname, lastname, startdate, starttime, endtime, hours FROM hoursworked WHERE startdate = Calendar332.SelectedDate AND startdate = Calendar333.SelectedDate ORDER By startdate

Dim strSQLconnection As String = Source=SQL Server;SERVER=123abc; Initial Catalog=abc; UID=xxxxxxx;PWD=xxxxxxx;

Dim sqlConnection As New Data.SqlClient.SqlConnection(strSQLconnection)
Dim sqlCommand As New Data.SqlClient.SqlCommand(sqlstring, sqlConnection)

Dim reader As Data.SqlClient.SqlDataReader = sqlCommand.ExecuteReader()

GridView7.Visible = True
GridView7.DataSource = reader
End Sub

Table structure:
id - auto increment
first name
last name

Data is test data like:
John Doe 2013-11-15 2013-11-15 8:00:00 AM 2013-11-15 5:00:00 PM 9:00

Thank you for any input you might be able to provide.

Reply With Quote