SqlDataAdapter da = new SqlDataAdapter("Select Id, CustId,Method FROM SCHeaders WHERE Id=23 ", conn);generates:
UPDATE [SCHeaders] SET [CustId] = @p1, [Method] = @p2 WHERE (([Id] = @p3) AND ((@p4 = 1 AND [CustId] IS NULL) OR ([CustId] = @p5)) AND ((@p6 = 1 AND [Method] IS NULL) OR ([Method] = @p7)))>
/// <summary> /// Update information /// </summary> /// <returns></returns> public Boolean UpdateRows(Boolean generateCommands = false) { Boolean results = false; try { if (generateCommands) { SqlCommandBuilder builder = new SqlCommandBuilder(adapter); builder.ConflictOption = ConflictOption.OverwriteChanges; builder.SetAllValues = false; // Set only changed values adapter.UpdateCommand = builder.GetUpdateCommand(true); } adapter.Update(this.table); results = true; } catch (Exception ex) { results = false; Logging.LogFormat(2, ex.Message); // at least log the problem } return results; }However, I am afraid it will not work as I want as the first option requires PrimaryKey to be set. I am not exactly sure how can I do this.