Click here to Skip to main content
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 23:58pm
Edited 21-Feb-13 0:33am
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
0 OriginalGriff 195
1 ProgramFOX 130
2 Maciej Los 105
3 Sergey Alexandrovich Kryukov 105
4 Afzaal Ahmad Zeeshan 82
0 OriginalGriff 6,564
1 Sergey Alexandrovich Kryukov 6,048
2 DamithSL 5,228
3 Manas Bhardwaj 4,717
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web03 | 2.8.1411022.1 | Last Updated 21 Feb 2013
Copyright © CodeProject, 1999-2014
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