1)I have two datasets data1 and data2. It should be noted that my data1 contains 10 rows and data2 contains 50 rows. Both datasets have a column named ID.
How to check that the data1 of ID is contained in the data2 of ID?
if Id present in second datset coulmn then save in list1 and not found in second datset then save in list2.
Amit MohantyPosted Aug 9, 2023, 12:25 PM
Check this
Amit MohantyPosted Aug 10, 2023, 6:51 AM
The error you're encountering ("Specified cast is not valid") occurs when there is a problem with the data type conversion. It's possible that the values in the "Emp_no" column of your DataEmp dataset are not valid integers. Try this
AmitPosted Aug 10, 2023, 6:21 AM
int id = Convert.ToInt32(row["ID"]); // Assuming "ID" is the column name in ExcelData if (DataEmp.Tables[0].AsEnumerable().Any(dataRow => dataRow.Field("Emp_no") == id)) showing error in Specified cast is not valid.
Cr BhargaviPosted Aug 9, 2023, 12:27 PM
AmitPosted Aug 9, 2023, 10:59 AM
i am using this two dataset to compair Id column .
1) DataSet ExcelData = new DataSet();
dataAdapter.Fill(ExcelData);
2) string Qry = @"SELECT Emp_no FROM EmployeeTable";
DataSet DataEmp = InProc.RetriveDataSet(Qry);
First ExcelData have 100 record and second DataEmp 500 record. I want to compair first datset to second datset if first dataset value present in second datset that value put in list and if data not present in scond datset put in second list.
Amit MohantyPosted Aug 9, 2023, 9:17 AM
Tahir AnsariPosted Aug 9, 2023, 9:15 AM
try sample logic: