Wrox Programmer Forums
Visual Basic 2010 General Discussion For any discussions about Visual Basic 2010 topics which aren't related to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2010 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old November 15th, 2013, 11:19 AM
Registered User
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.


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding hours and minutes together abhishekkashyap27 C# 2005 6 November 27th, 2009 03:25 PM
adding hours minutes and second Brendan Bartley Access 5 July 16th, 2009 09:35 AM
Calculate total hours based on Time deepcover1 Access 1 April 5th, 2006 01:50 AM
Accummulated Man-Hours mateenmohd SQL Server 2000 0 July 15th, 2005 11:31 AM
9 hours later still trying to do a login script sand133 VB.NET 2002/2003 Basics 5 June 24th, 2004 10:26 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.