School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 307,213 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,562 people online right now. Registration is fast and FREE... Join Now!




C# - Database help

 

C# - Database help

shuco

27 Nov, 2008 - 09:03 PM
Post #1

New D.I.C Head
*

Joined: 27 Nov, 2008
Posts: 2

I am not sure if this is the right forum, but since I am coding this in c# I would post it here.

I am writing my first database app (windows form in c#) and I am using an access database.

I have 2 tables with the following fields:

payroll
--Store
--lastName
--PayFreq
--SSN (PK)
--HireDate
--EffectiveDate
--TermDate
--DeductionCode
--Deduction
--NAD CHAR

hrconnection
--Store
--lastName
--CoTime
--Plan
--Dependants
--HireDate
--EffectiveDate
--TermDate
--SSN (PK)
--Deduction

First two queries:
I want to find the records based on SSN that are in the payroll table and are not in the hrconnection tables and then find the record based on SSN that are in the hrconnection but are not in the payroll table

For these I came up with


CODE
SELECT hrconnection.Store, hrconnection.lastName, hrconnection.HireDate, hrconnection.EffectiveDate, hrconnection.TermDate, hrconnection.SSN, hrconnection.Deduction "
                                + "FROM hrconnection LEFT JOIN payroll ON hrconnection.SSN = payroll.SSN "
                                + "WHERE (((payroll.SSN) Is Null))";


and
CODE
SELECT hrconnection.Store, hrconnection.lastName, hrconnection.HireDate, hrconnection.EffectiveDate, hrconnection.TermDate, hrconnection.SSN, hrconnection.Deduction "
                                + "FROM hrconnection LEFT JOIN payroll ON hrconnection.SSN = payroll.SSN "
                                + "WHERE (((hrconnection.SSN) Is Null))";


They don't really come out right. So I thought I would post here for some help on the first queries and the following queries.


Next query:
I want to find data that does not match between hrconnection and payroll then output which fields do not match and list what record has the mismatch last name and SSN next to them.

Next query
I want to take all the records that do match 100% and are in both tables add the deduction field for all record and output a total deduction.

Next Query.
I want to output all records that match 100% and are in both tables that are within 45 days of the effective date and list how many days they are away from the effective date.

Any help on these queries would be great!

Thanks

This post has been edited by shuco: 27 Nov, 2008 - 09:05 PM

User is offlineProfile CardPM
+Quote Post


newProgram

RE: C# - Database Help

27 Nov, 2008 - 11:30 PM
Post #2

D.I.C Head
**

Joined: 28 Oct, 2008
Posts: 152



Thanked: 4 times
My Contributions
QUOTE(shuco @ 27 Nov, 2008 - 09:03 PM) *

I am not sure if this is the right forum, but since I am coding this in c# I would post it here.

I am writing my first database app (windows form in c#) and I am using an access database.

I have 2 tables with the following fields:

payroll
--Store
--lastName
--PayFreq
--SSN (PK)
--HireDate
--EffectiveDate
--TermDate
--DeductionCode
--Deduction
--NAD CHAR

hrconnection
--Store
--lastName
--CoTime
--Plan
--Dependants
--HireDate
--EffectiveDate
--TermDate
--SSN (PK)
--Deduction

First two queries:
I want to find the records based on SSN that are in the payroll table and are not in the hrconnection tables and then find the record based on SSN that are in the hrconnection but are not in the payroll table

For these I came up with


CODE
SELECT hrconnection.Store, hrconnection.lastName, hrconnection.HireDate, hrconnection.EffectiveDate, hrconnection.TermDate, hrconnection.SSN, hrconnection.Deduction "
                                + "FROM hrconnection LEFT JOIN payroll ON hrconnection.SSN = payroll.SSN "
                                + "WHERE (((payroll.SSN) Is Null))";


and
CODE
SELECT hrconnection.Store, hrconnection.lastName, hrconnection.HireDate, hrconnection.EffectiveDate, hrconnection.TermDate, hrconnection.SSN, hrconnection.Deduction "
                                + "FROM hrconnection LEFT JOIN payroll ON hrconnection.SSN = payroll.SSN "
                                + "WHERE (((hrconnection.SSN) Is Null))";


They don't really come out right. So I thought I would post here for some help on the first queries and the following queries.


Next query:
I want to find data that does not match between hrconnection and payroll then output which fields do not match and list what record has the mismatch last name and SSN next to them.

Next query
I want to take all the records that do match 100% and are in both tables add the deduction field for all record and output a total deduction.

Next Query.
I want to output all records that match 100% and are in both tables that are within 45 days of the effective date and list how many days they are away from the effective date.

Any help on these queries would be great!

Thanks

QUOTE

Hi,

On your query, do not put an "=" operator in the from clause. And if you are just filtering the records on the database by SSN try to use this codes:
CODE

select * from payroll where SSN = "someValue"

on the second query:
CODE

select * from hrconnection where SSN = "someValue"

If the condition on the where clause is true then your query will produce the records base on the value you compare on the SSN.

User is offlineProfile CardPM
+Quote Post

shuco

RE: C# - Database Help

28 Nov, 2008 - 04:08 AM
Post #3

New D.I.C Head
*

Joined: 27 Nov, 2008
Posts: 2


Hi,

On your query, do not put an "=" operator in the from clause. And if you are just filtering the records on the database by SSN try to use this codes:
CODE

select * from payroll where SSN = "someValue"

on the second query:
CODE

select * from hrconnection where SSN = "someValue"

If the condition on the where clause is true then your query will produce the records base on the value you compare on the SSN.
[/quote]
[/quote]


Yes that would work if I was only looking at one table, but I am comparing two tables. so I would have to put an = so the join joins then by ssn correct ?
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 09:56PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month