I am trying to use the SalesforceCommandBuilder to generate an update sql for the account table and it gives me an exception when I try it with the default options (WHERE clause of the UPDATE statement can't be transformed to SOQL) . So I tried to set the KeyFields property without success... It is still adding more fields than expected...
WHERE clause generated:
Code: Select all
WHERE ((Id = :p6) AND ((:p7 = 1 AND No_d_etablissement_ZACK IS NULL) OR (No_d_etablissement_ZACK = :p8)) AND ((:p9 = 1 AND No_d_agence_ZACK IS NULL) OR (No_d_agence_ZACK = :p10)))
Code: Select all
cmdBuilder.UpdatingTable = "Account";
cmdBuilder.ConflictOption = ConflictOption.OverwriteChanges;
cmdBuilder.KeyFields = "Id";
cmdBuilder.SetAllValues = false;
string[] fields = {"Mot_de_passe", "Date_mot_de_passe", "ID_machine", "Mot_de_passe_machine", "Date_mot_de_passe_machine" };
adapter.UpdateCommand = cmdBuilder.GetUpdateCommand(fields, false);
adapter.UpdateCommand.Connection = sfConnection;
adapter.Update(accountsTable);
2- Why does the command builder doesn't use only the Id to generate the WHERE clause as specified by the KeyFields option
NOTE: If I set KeyFields to "Id, Name" it is adding Id, Name and the 2 other columns to the WHERE clause !
Thanks