Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 2010 > Visual Basic 2010 General Discussion
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 15th, 2013, 11:19 AM
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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 04:28 AM.

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