enter code hereI have two data tables one of the data tables connects to sql server and the other connects to oracle.
I am running query statements on both and those work perfectly find.
Now I need to write something that will compare the "UNIT_NO" in oracle to the "VehicleName" in sql. yes they are the same number.
Right now the Oracle table bring in 6 columns and the SQL brings in 4 columns
an example would be:
VehicleName, VehicleGroupName, UserDefinedColumn2, UserDefinedColumn3
Unit_No, Unit_ID, Using_Dept, Status, Using_Dept_Desc,
I want my code to find the matching number from Unit_NO and VehicleName and display all the above information all in one row. I was thinking linq but I cant get it to display correctly
This code combines the columns from both tables but pulls but does not add the any data in the rows any suggest or fixes
private void GetSQLOraclelinqData()
{
var TstarData = GetTrackstarTruckData();
var M5Data = GetM5Data();
DataTable ComTable = new DataTable();
foreach (DataColumn OraColumn in M5Data.Columns)
{
ComTable.Columns.Add(OraColumn.ColumnName, OraColumn.DataType);
}
foreach (DataColumn SQLColumn in TstarData.Columns)
{
if (SQLColumn.ColumnName == "VehicleName")
ComTable.Columns.Add(SQLColumn.ColumnName + 2, SQLColumn.DataType);
else
ComTable.Columns.Add(SQLColumn.ColumnName, SQLColumn.DataType);
}
var results = TstarData.AsEnumerable().Join(M5Data.AsEnumerable(),
a => a.Field<String>("VehicleName"),
b => b.Field<String>("Unit_NO"),
(a, b) =>
{
DataRow row = ComTable.NewRow();
row.ItemArray = a.ItemArray.Concat(b.ItemArray).ToArray();
ComTable.Rows.Add(row);
return row;
});
SQLDataTable.ItemsSource = ComTable.DefaultView;
}
my code is based off grabbing columns that are not populated yet in the datagrid I call two datatable on the code behind to populate the table and also us excel sheets. If anyone needs this information i can help.
I connect to SQL, Oracle and load excel sheets to make a comparison on data