private void UpdateFieldValueTest(Recordset recordset, string xlsPath) { try { string[] sheetNameList = importTool.GetSheetNameList(xlsPath); DataTable dt = importTool.ExcelToDataTable(xlsPath , sheetNameList[0]); // DataTable dt = importTool.ExcelToDataTable(xlsPath, "6.5.1综合经济指标表"); int length = recordset.RecordCount; if (length != 0) { /*需求:根据乡镇名字确定更新数据 1、选择成行改变:1)循环判断工作表中name列的所有记录,是否等于属性表中name列的第一行的内容 2)记录工作表中的对应的行数h 3)对数据集中特定字段逐行赋值*/ try { for (int m = 1; m <= length; m++)//行循环更新 { recordset.SeekID(m); recordset.Edit(); object name = recordset.GetObject("T_NAME"); seekExcel(name.ToString(), dt, recordset, m); } recordset.Update(); Msg("修改属性字段完成"); } catch (Exception ex) { Msg(ex.Message); } } else { Msg("记录集中没有记录"); } } catch (Exception ex) { Msg(ex.Message); } }