Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Best Practices = Database to C# class?

Posted on 2013-11-18
4
286 Views
Last Modified: 2013-11-19
Good Morning experts - I'm working at a steel plant currently and would like to do some analysis on some of the work that is being done - I was trying to create a C# application that will do analysis and then export it into excel or some other reporting "thing"...

For a very simple example lets say my query looks like:

SELECT        STUPP_COIL, PO_NUMBER, RUN_DATE, COIL_WEIGHT
FROM            APPCOILS.COILS
WHERE        (TO_CHAR(RUN_DATE, 'MM/DD/YYYY') = '11/18/2013') AND (JOB = '9370')
ORDER BY STUPP_COIL

(the job and the date will be entered at the program, not hard coded into the query)

this will pull back about 60-70 "Coils" of steel per day,

If I had a class that had Coil#, po# and RunDate, and weight for the example how would I assign each coil an item in a list (for example) so I could add up all the weights, or see how many coils are being run per day, per hour, etc...

This is a very simplified example so I can hopefully understand the concept - The actual table has about 60 columns in it (I dont need them all, but I figured if I could do it with the bare minimum I could always scale it up)

Could someone point me to the correct direction on what I am trying to do?

I guess I do not know it enought to know exactly WHAT to ask... So, if anyone can help, I would appreciate it.

Thank you.
0
Comment
Question by:hej613
  • 2
  • 2
4 Comments
 
LVL 16

Expert Comment

by:Easwaran Paramasivam
ID: 39657191
Have the datetime column for RUN_DATE and have the value with time appropriately.

Use below query to identify the jobs for given date range.

SELECT        STUPP_COIL, PO_NUMBER, RUN_DATE, COIL_WEIGHT
FROM            APPCOILS.COILS
WHERE  (RUN_DATE BETWEEN '20131118 01:00:10' AND '20131119 06:00:00' ) AND (JOB = '9370')

You could give the date and time FROM and TO range in where clause.
The general date should be in the format YYYYMMDD HH:MM:SS

HTH.
0
 
LVL 1

Author Comment

by:hej613
ID: 39658249
Thanks, Easwaran - I understand the SQL portion of it, I guess I was not specific enough with the question...

Once I use that SQL and pull back the rows, What should I do with them so I can do some analysis of the data?  Should I put the values in a list, should I put them in a DataAdapter/DataTable and use a LINQ query?  

What is the best way to deal with the information so I can do some analysis of some sort on it? adding up the weights, counting different coils by different status, etc, etc.

Could you or someone point me in the correct direction on what to do with the rows I get back?  a few links would be amazing, a book recommendation would also be great, is it ADO I'm looking into? Thank you.
0
 
LVL 16

Accepted Solution

by:
Easwaran Paramasivam earned 500 total points
ID: 39658401
In this case LINQ is the best option.  Like SQL you could perform whatever operation you like such as sort, select, group, order and so forth.

I refer Linq in action book http://www.manning.com/marguerie/ and C# in depth http://www.manning.com/skeet/

Below lik could be useful http://code.msdn.microsoft.com/101-LINQ-Samples-3fb9811b

HTH.
0
 
LVL 1

Author Closing Comment

by:hej613
ID: 39659549
Thank you very much :)
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Change to file doesn't show up 16 54
Help With SQL Query 9 32
job schedule 8 20
How can I do Unit Testing with Session ? 1 12
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question