Click here to Skip to main content
15,887,939 members
Home / Discussions / C#
   

C#

 
GeneralRe: Admin questions about Microsoft exam 70-483 Pin
Mycroft Holmes23-Apr-15 12:56
professionalMycroft Holmes23-Apr-15 12:56 
QuestionHow to compare a sql server table field with a csv field and display what is not in the sql table. Pin
Norris Chappell23-Apr-15 4:33
Norris Chappell23-Apr-15 4:33 
AnswerRe: How to compare a sql server table field with a csv field and display what is not in the sql table. Pin
Sascha Lefèvre23-Apr-15 4:49
professionalSascha Lefèvre23-Apr-15 4:49 
GeneralRe: How to compare a sql server table field with a csv field and display what is not in the sql table. Pin
Norris Chappell23-Apr-15 5:44
Norris Chappell23-Apr-15 5:44 
GeneralRe: How to compare a sql server table field with a csv field and display what is not in the sql table. Pin
Sascha Lefèvre23-Apr-15 5:56
professionalSascha Lefèvre23-Apr-15 5:56 
GeneralRe: How to compare a sql server table field with a csv field and display what is not in the sql table. Pin
Norris Chappell23-Apr-15 6:20
Norris Chappell23-Apr-15 6:20 
GeneralRe: How to compare a sql server table field with a csv field and display what is not in the sql table. Pin
Kevin Marois23-Apr-15 6:37
professionalKevin Marois23-Apr-15 6:37 
GeneralRe: How to compare a sql server table field with a csv field and display what is not in the sql table. Pin
Sascha Lefèvre23-Apr-15 6:55
professionalSascha Lefèvre23-Apr-15 6:55 
Alright. I would suggest:

1) Your original code looks like you not only want the names of the persons but also their total hours and "FTE". At least the total hours are easy to calculate in the same query, using a GROUP BY-clause and the Sum()-function. Tune that query in SQL Server Management Studio (or whatever you're using) so that you get exactly the query result you want to display, possibly except those "FTE". (If you're not familiar with GROUP BY, please take a look at the MSDN online documentation, there should be a sample that also shows the Sum()-function.)

2) Either have that temporary table as a permanent table in your DB (which you would clear after use) or write some C#-code that creates an actual temporary table. SQL Server Management Studio can produce a CREATE TABLE-script for you from your current test-table which you would practically only have to execute from C# with an SqlCommand and ExecuteNonQuery(). (Just add a # to the start of the table name to make it a temp table.)

3) Get that CSV-Reader-library that I linked in my first reply running and read the CSV-file (that's a piece of cake).

4) Write the code that inserts the CSV-records into the (temp) table.

5) Write the code that executes the query from point 1 and read the result into a DataTable.

6) If you didn't calculate the "FTE" with the SQL-Query, add a new DataColumn to the DataTable and "fill" it.

7) Set the DataTable as DataSource for your DataGrid and you're done.

One more Hint: Temp tables are valid throughout the course of a connection. So you will have to use the same open connection from creating the temp table to reading the query result.


(I'm packing up for today - if you have follow-up questions, maybe someone else will be able to answer them, else I'll get back to you tomorrow.) Good luck!
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

GeneralRe: How to compare a sql server table field with a csv field and display what is not in the sql table. Pin
Norris Chappell23-Apr-15 13:21
Norris Chappell23-Apr-15 13:21 
GeneralRe: How to compare a sql server table field with a csv field and display what is not in the sql table. Pin
Sascha Lefèvre24-Apr-15 3:00
professionalSascha Lefèvre24-Apr-15 3:00 
GeneralRe: How to compare a sql server table field with a csv field and display what is not in the sql table. Pin
Norris Chappell24-Apr-15 5:25
Norris Chappell24-Apr-15 5:25 
AnswerRe: How to compare a sql server table field with a csv field and display what is not in the sql table. Pin
Sascha Lefèvre24-Apr-15 11:04
professionalSascha Lefèvre24-Apr-15 11:04 
GeneralRe: How to compare a sql server table field with a csv field and display what is not in the sql table. Pin
Norris Chappell24-Apr-15 11:57
Norris Chappell24-Apr-15 11:57 
GeneralRe: How to compare a sql server table field with a csv field and display what is not in the sql table. Pin
Sascha Lefèvre24-Apr-15 12:56
professionalSascha Lefèvre24-Apr-15 12:56 
GeneralRe: How to compare a sql server table field with a csv field and display what is not in the sql table. Pin
Norris Chappell25-Apr-15 13:28
Norris Chappell25-Apr-15 13:28 
GeneralRe: How to compare a sql server table field with a csv field and display what is not in the sql table. Pin
Sascha Lefèvre25-Apr-15 13:42
professionalSascha Lefèvre25-Apr-15 13:42 
GeneralRe: How to compare a sql server table field with a csv field and display what is not in the sql table. Pin
Norris Chappell25-Apr-15 13:50
Norris Chappell25-Apr-15 13:50 
GeneralRe: How to compare a sql server table field with a csv field and display what is not in the sql table. Pin
Sascha Lefèvre25-Apr-15 14:02
professionalSascha Lefèvre25-Apr-15 14:02 
GeneralRe: How to compare a sql server table field with a csv field and display what is not in the sql table. Pin
Norris Chappell25-Apr-15 14:08
Norris Chappell25-Apr-15 14:08 
GeneralRe: How to compare a sql server table field with a csv field and display what is not in the sql table. Pin
Norris Chappell25-Apr-15 14:11
Norris Chappell25-Apr-15 14:11 
GeneralRe: How to compare a sql server table field with a csv field and display what is not in the sql table. Pin
Norris Chappell25-Apr-15 14:13
Norris Chappell25-Apr-15 14:13 
GeneralRe: How to compare a sql server table field with a csv field and display what is not in the sql table. Pin
Sascha Lefèvre25-Apr-15 15:11
professionalSascha Lefèvre25-Apr-15 15:11 
GeneralRe: How to compare a sql server table field with a csv field and display what is not in the sql table. Pin
Norris Chappell25-Apr-15 15:28
Norris Chappell25-Apr-15 15:28 
GeneralRe: How to compare a sql server table field with a csv field and display what is not in the sql table. Pin
Norris Chappell25-Apr-15 15:35
Norris Chappell25-Apr-15 15:35 
GeneralRe: How to compare a sql server table field with a csv field and display what is not in the sql table. Pin
Sascha Lefèvre25-Apr-15 15:41
professionalSascha Lefèvre25-Apr-15 15:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.