Click here to Skip to main content
11,796,631 members (72,914 online)
Rate this: bad
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
Rate this: bad
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[^].
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
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

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

  Print Answers RSS
0 Maciej Los 505
1 Abhinav S 417
2 OriginalGriff 360
3 CPallini 285
4 KrunalRohit 249
0 OriginalGriff 2,012
1 Maciej Los 1,725
2 KrunalRohit 1,310
3 CPallini 1,055
4 ppolymorphe 858

Advertise | Privacy | Mobile
Web03 | 2.8.151002.1 | 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