I have 2 datatables that came from 2 different sql (msSQL and MySQL) with one similar column data.
DataTable 1 : employeeno, device, devicestatus
DataTable 2 : employeeno, name, employeestatus
I probably need to run a foreach with multiple IFs on the Datatable 1 againts Datatable2 and put result to Datatable3 as such :
     DataTable ResultDataTable = new DataTable("ResultDataTable");
            foreach (DataRow dr in myPHPdt.Rows)
            {
                string checkEmpNo = dr.Table.Rows;
                myPHPdt.Select(checkEmpNo);
                if (/*Some Condition here*/ )
                {
                    if (/*Some Condition here*/ )
                    {
                        if (checkEmpNo = '999999')
                        {
                            LMTF.LogMessageToFile("This is skipped");
                        }
                        ResultDataTable.Rows.Add(dr.ItemArray);
                        DefaultCellStyle.BackColor = Color.Red;
                    }
                    ResultDataTable.Rows.Add(dr.ItemArray);
                }
            }
            dataGridView3.DataSource = ResultDataTable;
The problem that i have is how do i check each row of employeeno with multiple IFs in DataTable1 to compare with DataTable2?
Also something wrong with the "string checkEmpNo = dr.Table.Rows" part as it is suppose to return the employeeno of the row it is currently in.
Requirement :
If Employeeno in DataTable1 exist in DataTable2 - Add to DataTable3 rows.
If employeestatus of Employeeno is Terminated - Add to DataTable3 rows with row colour red.
If employeeno in DataTable1 equal to 999999 , do nothing.
Is this even possible to do with DataTable comparison method?
Is there a better method to do this?
Edit 1 - 12/3/2020
I have tried this - but it did not return any result , though it did show the Column Names. ( feels like the DataRows are empty )
DataTable targetTable = new DataTable();
            var dt2Columns = myPHPdt.Columns.OfType<DataColumn>().Select(dc => new DataColumn(dc.ColumnName, dc.DataType, dc.Expression, dc.ColumnMapping));
            var dt2FinalColumns = from dc in dt2Columns.AsEnumerable()
                                  where targetTable.Columns.Contains(dc.ColumnName) == false
                                  select dc;
            targetTable.Columns.AddRange(dt2FinalColumns.ToArray());
            var rowData = from row1 in myPHPdt.AsEnumerable()
                          join row2 in orisoftdt.AsEnumerable()
                          on row1["employeeno"] equals row2["EMPLOYEE_ID"]
                          select row1.ItemArray.Concat(row2.ItemArray.Where(r2 => row1.ItemArray.Contains(r2) == false)).ToArray();
            foreach (object[] values in rowData)
                targetTable.Rows.Add(values);
            dataGridView3.DataSource = targetTable;
