LPARAMETERS tcTable, tcAlias, tlHasCalcFields, tcSpecialFields LOCAL cPK, lPKIsIdentity, lSuccess lSuccess = .T. CURSORSETPROP("Tables", "dbo." + m.tcTable, m.tcAlias) CURSORSETPROP("WhereType", 1, m.tcAlias) * Find PK cPK = This.GetPK(m.tcTable) IF NOT EMPTY(m.cPK) CURSORSETPROP("KeyFieldList", m.cPK, m.tcAlias) * Only need to check for identity column if * the PK is a single field. IF NOT "," $ m.cPK lPKIsIdentity = This.IsIdentity(m.cPK, m.tcTable) ELSE lPKIsIdentity = .F. ENDIF ENDIF LOCAL cFieldList, cUpdateNameList, aFieldList[1], nFields, nField nFields = AFIELDS(aFieldList, m.tcAlias) cFieldList = "" cUpdateNameList = "" IF m.tlHasCalcFields IF SQLCOLUMNS(This.nHandle, m.tcTable, "FOXPRO", "csrColumns") <> 1 lSuccess = .F. ENDIF ENDIF IF m.lSuccess FOR nField = 1 TO m.nFields * Modified 19-October-2011 by TEG * If necessary, check whether the field exists in the table. IF m.tlHasCalcFields SELECT csrColumns LOCATE FOR UPPER(csrColumns.Field_Name) = UPPER(aFieldList[m.nField, 1]) IF NOT FOUND("csrColumns") LOOP ENDIF ENDIF IF NOT (UPPER(aFieldList[m.nField, 1]) == UPPER(m.cPK)) OR ; NOT m.lPKIsIdentity * Don't put identity field in list of updateable fields * Wrap field name in brackets in case it's a reserved word. cFieldList = m.cFieldList + ", " + aFieldList[m.nField, 1] ENDIF cUpdateNameList = m.cUpdateNameList + ", " + ; aFieldList[m.nField, 1] + ; " dbo." + ALLTRIM(m.tcTable) + ".[" + aFieldList[m.nField, 1] + "]" ENDFOR cFieldList = SUBSTR(m.cFieldList, 3) cUpdateNameList = SUBSTR(m.cUpdateNameList, 3) CURSORSETPROP("UpdatableFieldList", m.cFieldList, m.tcAlias) CURSORSETPROP("UpdateNameList", m.cUpdateNameList, m.tcAlias) CURSORSETPROP("SendUpdates",.T., m.tcAlias) ENDIF RETURN m.lSuccessIt assumes that the original table name and the alias can be different (which is something we need to support, since it's not unusual in this app to pull more than one data set from the same table). The GetPK method queries the information_schema table and builds a comma-separated list of fields marked as primary keys.