Click here to Skip to main content
11,571,102 members (67,176 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# SQL SQL-Server-2008
I have two tables Employee Details and EmpAttendance.

Employee Details has EmployeeID ,EmployeeNAME, EMailID columns.
EmpAttendance has c_Date , Eid, Intime, Outtime,Count columns.

i have a form in windows app, when we type employeeID and press Submit Button, I need to display


S.NO c_Date EmployeeID EmployeeNAME EMailID Intime Outime Count TotalWorkingHours


where TotalWorkingHours is the difference between outtime and intime.


suggest me how to do this.
Posted 20-Feb-13 22:58pm
Edited 20-Feb-13 23:33pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You need to start with database basics.
Do a join between the two tables and subrtact the datetimes values for intime and outtime to get totalworking hours.

Simple Database Application - Part 1[^] should help you get started.

For datetime calculations on query, try http://msdn.microsoft.com/en-us/library/ms189794.aspx[^].
  Permalink  
Comments
Vardhan Desai at 21-Feb-13 5:12am
   
There is no Foreign Key in EmpAttendance or Matching values, so no join is possible.

--Regards Vardhan Desai
Bala Selvanayagam at 21-Feb-13 5:30am
   
Do we need a foreign key actually defined in order to do a join ?
Vardhan Desai at 21-Feb-13 7:02am
   
Not necessary but a matching column values with same datatype should be there for Join condition.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Make a Foreign Key in Table EmpAttendance with respect to EmployeeID; then do Join with matching this columns.

--Regards Vardhan Desai
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


Advertise | Privacy | Mobile
Web03 | 2.8.150624.2 | Last Updated 21 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100