DataTable dataTable = GetTable(); if (dataTable.Rows.Count > 1) { for (int i = 0; i < dataTable.Rows.Count; i++) { var dataRow = dataTable.Rows[i]; if (dt.Rows.Contains(dataRow) && dt.Rows.Count != 0)
I assume that your dt variable should be your dataTable variable, if you get an error message indicating that your table does not have a primary key, it could be because you are using the wrong variable and that there really is no primary key or table associated with the variable you are trying to use.
so I assume the code should look like this:
DataTable dataTable = GetTable(); if (dataTable.Rows.Count > 1) { for (int i = 0; i < dataTable.Rows.Count; i++) { var dataRow = dataTable.Rows[i]; if (dataTable.Rows.Contains(dataRow) && dataTable.Rows.Count != 0)
source share