I would like to compare a CSV field "Name" with a SQL Server table field "ResourceName" and write out the person that is not in the SQL server table.

if (this.DataCenterLaborFileUpload.HasFile)
                var extension = Path.GetExtension(DataCenterLaborFileUpload.FileName);
                string currentName = "";
                decimal currentHours = 0.00M;
                decimal currentFTE = 0.00M;
                string ResourceName = "";
                if (extension == ".csv")
                    StreamReader csvreader = new StreamReader(DataCenterLaborFileUpload.FileContent);
                    DataTable dt = new DataTable();
                    dt.Columns.Add("txtName");
                    dt.Columns.Add("txtHours");
                    dt.Columns.Add("txtFTE");
                    while (!csvreader.EndOfStream)
                        DataRow dr = dt.NewRow();
                        var line = csvreader.ReadLine();
                        var values = line.Split(',');
                        if (values[0].Trim() != "Pers.No.")
                            using (DbConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLStaffingConn"].ConnectionString))
                                conn.Open();
                                using (DbCommand cmd = conn.CreateCommand())
                                    cmd.Connection = conn;
                                    cmd.CommandText = "SELECT ResourceName FROM
StaffTracking  order by PersonnelResourceType, ResourceName";
                                 //   DbParameter p1 = cmd.CreateParameter();
                                 //   p1.ParameterName = "restype";
                                 //   p1.Value = "Supplier";
                                 //   cmd.Parameters.Add(p1);
                                    using (DbDataReader row = cmd.ExecuteReader())
                                        while (row.Read())
ResourceName = row.GetString(0);
if (ResourceName != (values[1].Trim()))
if (values[1].Trim() == currentName)
currentHours = currentHours + Convert.ToDecimal(values[9].Trim());
else
if (currentName == "")
dr["txtName"] = currentName;
dr["txtHours"] = currentHours;
dr["txtFTE"] = currentFTE + Math.Round(currentHours / (weekdaysInMonth() * 8), 2);
dt.Rows.Add(dr);
dt.AcceptChanges();
currentHours = Convert.ToDecimal(values[9].Trim());
currentName = values[1].Trim();
                    DataRow drfinal2 = dt.NewRow();
                    drfinal2["txtName"] = currentName;
                    drfinal2["txtHours"] = currentHours;
                    drfinal2["txtFTE"] = currentFTE + Math.Round(currentHours / (weekdaysInMonth() * 8), 2);
                    dt.Rows.Add(drfinal2);
                    dt.AcceptChanges();
                    gvDataCenterLabor.DataSource = dt;
                gvDataCenterLabor.DataBind();
                //     Page.DataBind();
Here is my csv file:
Pers.No.
Name
HomeFID
Copy Range/Value from Column V
Worked Date
Job Code
Account
Pay Type
Activity Type
Hours
11111111
Doe Jane
USA7064810
US1-08333.01.08.02.03
20150223
00S15H
9.61E+09
410
8
11111111
Doe John
USA7064810
US1-08333.01.08.02.03
20150210
00S15H
9.61E+09
410
9
11111111
Smith Jane
USA7064810
US1-08333.01.08.02.03
20150226
00S15H
9.61E+09
410
8
So if Doe Jane is not in the SQL table I would like to only display her.
It's only displaying the ones from the CSV file that are in the SQL Table.
Thanks

Hi
Please use this insert
code button to provide code next time. It could better to help us to review  your code.
Now let's focus your question, I have tried to test with your code. But failed.
I would suggest that you could export columns "Name" and "ResourceName" to DataTable.
Then use DataTable to compare and filter with its column value.
Here is a helpful reference:
Comparingtwo DataTables by specific
column in C# [closed]
Best regards,
Kristin
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

Maybe you are looking for

  • What is the minimum spec for a Macbook Pro to run FCPX?

    I have FCP X installed on my 2009 iMac which has 8Gb of RAM. It works okay, more or less, but I need the portability of a laptop. As cash matters, what is the cheapest Macbook Pro option?  I would boost the RAM to 8gb but what else woud I need? I wou

  • Outgoing messages not working with POP e-mail account

    I am getting a strange message each time I try to send outgoing e-mail messages with my iPhone 3G. It says that my recipients e-mail address in invalid. I have tried multiple e-mail addresses and it always says the same thing when I try to send. My o

  • Mail not received from Apple

    I recently tried to obtain an Aperture serial number and through the process found out that I am not receiving emails from Apple. With an Apple tech support's help, was able to get her basic email but one with any links in the body of the message, wo

  • Need solid pro dj software for live mixing-any suggestions?

    Tried Traktor, PCDJ and Virtual DJ with my Dell-with good results-recently converted to the MacBook Pro and love it. PC gone bye bye! Need solid pro dj software for club mixing. Thanks, ps I saw Michael Dell recently at a Texas Rangers game....with a

  • DPS Viewer for Android mobiles

    Since we launched our publication on the IPAD and the IPhone, we have been receiving alot of requests from customers to launch the publication on android devices. After doing some survey, most of the requests are coming from people with Samsung S2, S